local VanFloor = game.Workspace.ucb.vantruck.VanFloor
VanFloor.Touched:Connect(function(itemTouchingPart) print("Item touching part: ", itemTouchingPart)
if(itemTouchingPart.Parent and game.Players:FindFirstChild(itemTouchingPart.Parent.Name))then print("There is a player touching the part!") else v.Character.Humanoid.Health = 0 end
My problem is in v.Character it says v is unknown, how do I define v?,
You basically want to kill a player if their item is touching a part, right? this is a script to kill the player if either that player or their item is on a part;
-- in this example, MyKillBrick is the part you want to do the killing function onTouched(part) local hum = part.Parent.Humanoid if hum == nil then local tool = part:FindFirstAncestorWhichIsA("Tool") if tool ~= nil then hum = tool.Parent.Humanoid end end print("Good So Far") wait() if hum then hum.Health = 0 end end MyKillBrick.Touched:Connect(onTouched)
EDIT: Try this. Put these 1st script in the part you want and put a BoolValue named "TouchingFloor" in StarterCharacterScripts 1st Script:
function onLeft(part) local hum = part.Parent.Humanoid if hum == true then part.Parent.TouchingFloor.Value = false end end function onTouched(part) local hum = part.Parent.Humanoid if hum == true then part.Parent.TouchingFloor.Value = true end end script.Parent.TouchEnded:Connect(onLeft) script.Parent.Touched:Connect(onTouched)
Here is the second script. Put this also in StarterCharacterScripts:
while true do wait(0.5) if script.Parent.TouchingFloor.Value == false then repeat x= x + 1 wait(0.1) until x == 5 or script.Parent.TouchingFloor.Value == true if script.Parent.TouchingFloor.Value == false then script.Parent.Humanoid.Health = 0 end end end
This will Punish the player for having none of them touch the floor (or whatever part) for over a 1/2 second. I did this because their animation might have them leave the floor for a split second. Respond if this doesnt work and i'll get back to you ASAP