@iy_uhn
Touched Events can’t be detected when using a Local Script, unless the local script is parented to the player, PlayerGUI (Starter Gui before instantiated) or PlayerScripts, StarterCharacterScripts.
Make sure you’re using a Server Script to detect the .Touched event.
Edit: Can we see your code to tell you what’s wrong?
local debounce = false
part.Touched:Connect(function(hit)
if not debounce and hit.Parent:FindFirstChild("Humanoid") then
debounce = true
hit.Parent.Humanoid.WalkSpeed = 20 --Sets walkspeed
wait(5)
debounce = false --Ends debounce
end
end)
@GalaxyGourmet Unless you add some sort of Debounce to that code, it will fire hundreds of times, which is not something you want.
Edit : I see you added debounce, but not the right way.
And by the way,
Just dumping code here without any explanation won’t help the OP at all, unless you know or at least, are explaining what the lines of code actually do. @C0lvy123 on the other hand, that’s a satisfactory explanation!
A player’s character is just a model with a bunch of limbs, customization stuff, and a humanoid. Whenever a player touches a part, it’s one of their limbs that touches it. Like the bottom half of their leg or their torso. So to check if it was a player that touches a part, all you have to do is check if it is “Siblings” with a humanoid. For example:
Part.Touched:Connect(function(Hit)
-- Hit represents the part that made the touched event fire
if Hit.Parent.Humanoid then
print("A player's limb touched the part")
end
end)
Now all you have to do is change the player’s humanoid’s WalkSpeed property to 0, like this:
Part.Touched:Connect(function(Hit)
if Hit.Parent.Humanoid then
Hit.Parent.Humanoid.WalkSpeed = 0
end
end)
(Sorry if I didn’t explain it that well)
This is basically what someone’s character looks like:
game < Workspace < C0lvy123 < Torso, LeftLeg, RightLeg, Head, Humanoid, Hat