Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

2 comments

0

16 is the default WalkSpeed.

0

yes, but the shop made the player's walkspeed 0 when the player entered the shop.

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.