Hey, I did not ask a question for a longer time. (I guess thats good tho)
Problem
I am trying to make a script that kills a player after some time if they do not touch a part.
Script
for i, user in ipairs(game.Players:GetChildren()) do local char = user.Character local part = workspace.InZone local h = part.Parent:FindFirstChild("Humanoid") if h~= nil then h.Health = h.Health -200 end end
I seriously don't see why you bother with this workspace.InZone thing. Also is this a script or localscript? (It should be a script)
for i, user in ipairs(game.Players:GetChildren()) do local char = user.Character char:FindFirstChild("Humanoid") if h~= nil then h.Health = h.Health -200 end end
In order to do this, you must make a loop to count time and a checker for when the part has been touched. There are 2 functions that do this, :GetTouchingParts()
Or the event, Touched
. Here are wiki articles for them:
Touched
GetTouchingParts
If you have anymore questions reply to this answer.
Try This:
for i, user in ipairs(game.Players:GetChildren()) do local char = user.Character local humanoid = char.Humanoid humanoid.Health = humanoid.Health - 100 end
Make sure it is a Script not a LocalScript.
Hope this helps!