Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to make When entering a specific area and change WalkSpeed?

Asked by 4 years ago
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)

3 answers

Log in to vote
0
Answered by 4 years ago

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)
Ad
Log in to vote
0
Answered by 4 years ago

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!

0
i cant understand pls write script Green_SteveYT 8 — 4y
0
I'm not here to write the code for you. What don't you understand? Maybe I can help SussiestBalss 40 — 4y
1
Here you could actually write him an example script. So he learns how Region3 works Spjureeedd 385 — 4y
Log in to vote
0
Answered by
MediaHQ 53
4 years ago

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!

0
this will work but it wont reset the speed when exiting the area Pitched_mobile 191 — 4y
0
its not working Green_SteveYT 8 — 4y

Answer this question