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

Why does it not set the player's walkspeed to 16?

Asked by 4 years ago

This script is fired when the player clicks the exit button on a shop. This script for some reason doesn't change the player's walkspeed

game.ReplicatedStorage.CloseShop.OnServerEvent:Connect(function(player)

    game.Workspace[player.Name].HumanoidRootPart.CFrame=game.Workspace.SHOP.ExitShopPart.CFrame


    game.Workspace:FindFirstChild(player.Name).Humanoid.WalkSpeed = 16

end)

And whats weird is that if I change this value to 17 or 15 it changes. Why is it doing this?

0
16 is the default WalkSpeed. Ziffixture 6913 — 4y
0
yes, but the shop made the player's walkspeed 0 when the player entered the shop. YazaTheGreat 5 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Okay, so if anybody gets this same problem I found the fix.

What i did to combat this problem was that I made a remote event which was fired when the player closed the shop.

Script

game.ReplicatedStorage.CloseShop.OnServerEvent:Connect(function(player)

game.Workspace[player.Name].HumanoidRootPart.CFrame=game.Workspace.SHOP.ExitShopPart.CFrame

    game.ReplicatedStorage.SetSpeed:FireClient(player) -- the remote event that was fired

end)

Then, I had a local script listening for the remote event. When the event was fired, this script set the player's walkspeed to 16

Local script

local replicatedStorage = game:GetService("ReplicatedStorage")

replicatedStorage.SetSpeed.OnClientEvent:Connect(function()
    game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end)

I still have no idea why my script didn't like to change the walkspeed to 16 but this is the fix!

Ad

Answer this question