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;
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)
If this doesnt work or isnt what you intended, comment on this and I'll see what I can do. If it is good, you can accept my answer ;)
IGNORE EVERYTHING BEFORE HERE
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
2 comments
You can use the event touch ended.
how?