local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = char:FindFirstChild("Humanoid")
local speed = script.Parent.SpeedValue
script.Parent.Touched:Connect(function()
humanoid.WalkSpeed = speed.Value
end)
✓ ANSWER ACCEPTED
How to make When entering a specific area and change WalkSpeed?
3 answers
✓ Accepted answer
put this in a script in ServerScriptService
game.Workspace.Part.Touched:Connect(function(hit) --specify ur part
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Character:FindFirstChild("Humanoid").WalkSpeed = 50 --speed inside of the area
end
end)
game.Workspace.Part.TouchEnded:Connect(function(hit) --specify the part
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Character:FindFirstChild("Humanoid").WalkSpeed = 16 -- speed exiting the area
end
end)
Try using region3 and constantly checking if the player is in the region3. If they are, then set their walkspeed. Let me know if it works!
You are using a localscript to change a players walkspeed. Either that or you're using a LocalPlayer in a normal script. You can get a player's character by doing this
local speed = script.SpeedValue --Put the speedvalue inside the script
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Walkspeed = speed.Value
end
end)
Let me know if this works!
2 comments
0
this will work but it wont reset the speed when exiting the area
0
its not working
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
i cant understand pls write script
I'm not here to write the code for you. What don't you understand? Maybe I can help
Here you could actually write him an example script. So he learns how Region3 works