Hey there all,
I’ve been running into this issue where a TouchedEvent is not working the way I want it to. What I’m trying to create is where when you touch a part it slows down the player.
But in the video shown below, it slows down the player and speeds the player back up when they exit the part, and then completely breaks once you try to touch it again.
Here is my code (In a ServerScript ) :
for _, part in WalkspeedChangerFolder:GetChildren() do
if not part:IsA("Part") then return end
if not part:GetAttribute("SetWalkspeed") then return end
part.Touched:Connect(function(hit)
if not hit.Parent then return end
if not hit.Parent:FindFirstChild("Humanoid") then return end
local Humanoid: Humanoid = hit.Parent:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = part:GetAttribute("SetWalkspeed")
end)
end
Thanks a lot!