Trying to get a trainkill command to work.

(Garry’s Mod Dedicated server made with SteamCMD) So, pretty much what the titles says. I have ulx, and I just got some code from a different post and tried to fix it. But, I get an error (I suck at lua.:ohno:).

This is the code I’m trying to use:

------------------------------ Train Kill ------------------------------
function SpawnTrain( Pos, Direction )
local train = ents.Create( “prop_physics” )
train:SetModel(“models/props_trainstation/train001.mdl”)
train:SetAngles( Direction:Angle() )
train:SetPos( Pos )
train:SetCustomCollisionCheck
train:Spawn()
train:ShouldCollide( Entity train, Entity player)
train:Activate()
train:EmitSound( “ambient/alarms/train_horn2.wav”, 100, 100 )
train:GetPhysicsObject():SetVelocity( Direction * 100000 )

timer.Create( "TrainRemove_"..CurTime(), 5, 1, function() if not IsValid(train) then return end train:Remove() end)

end

function ulx.trainkill( calling_ply, target_plys )
for _, ply in ipairs( target_plys, calling_ply ) do

	local Hp = ply:Health()
	local Dif = Hp - 0
	local HpOut = Hp - Dif
	local HpSur = Hp + Dif
	
	ply:SetMoveType( MOVETYPE_WALK )
	ply:GodDisable()
	ply:SetHealth(HpOut)
	SpawnTrain( ply:GetPos() + ply:GetForward() * 750 + Vector(0,100,0), ply:GetForward() * -1 )
	ply:GodDisable()
	ply:SetMoveType( MOVETYPE_WALK )
	
	timer.Create( "trainKillNot_", 6.5, 1, function( target_plys )
		if ply:Alive() then ply:SetHealth(HpSur) else end
	end )
	
end

ulx.fancyLogAdmin( calling_ply, "#A trainkilled #T", target_plys )

end

And this is the bit of code I tried to put in myself. (Again, I just started coding about a week ago. I’m still watching tutorials. I am pretty thick headed.) :

train:ShouldCollide( Entity train, Entity player)

I know this is horrible, but at least I tried xD. Any suggestions on how to fix this?


(User was banned for this post ("Use 


 tags and see Developer Discussion for help!" - NiandraLades))

So basically Evolve’s trainfuck in ULX?