local db = false game.Workspace.Part.Touched:Connect(function() if not db then db = true print("I was stepped on :(") wait(10) db = false end end)
It's going to print that everytime i step on it and wait 10 seconds before it fires again.
Now if a make a server where atleast 2 players are in; if i step on the part it waits 10 seconds, if i go to the other client and press on the part it waits???
I don't understand because it's in a local script???
You are not checking if hit is from your character, other people count as parts too, solution? check if part is descendant of your character. Also if any other object touches it, it also can start because touched means that when any base part touches it, it fires. Here is a fix:
local player = game.Players.LocalPlayer -- local player local character = player.Character or player.CharacterAdded:Wait() -- gets character workspace:WaitForChild("Part").Touched:Connect(function(hit) -- define hit so we can work with it soon if hit:IsDescendantOf(player.Character) then -- if part is inside of character print("hello") end end)
Also i used waitForChild there as it is very important, if script executes faster than the part loads, it errors.