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

Local Script won't change WalkSpeed?

I have no idea why this is happening but I made it so they can't walk (and jump) when they join (on the server) but when they press the start button they can move again (on the client).

Here are the scripts:

Server Script:

game.Players.PlayerAdded:Connect(function(plr)
	
	local character = plr.Character or plr.CharacterAdded:Wait()
	
	character.Humanoid.WalkSpeed = 0
	character.Humanoid.JumpPower = 0
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = plr
	leaderstats.Name = "leaderstats"
	
	local Wins = Instance.new("IntValue")
	Wins.Parent = leaderstats
	Wins.Name = "Wins"

end)

Local Script:

local localPlayer = game.Players.LocalPlayer
local humanoid = localPlayer.CharacterAdded:Wait():WaitForChild("Humanoid")
script.Parent.MouseButton1Click:Connect(function(plr)
	script.Parent.Parent.Parent.Enabled = false
	if plr == localPlayer then
		humanoid.WalkSpeed = 16
		humanoid.JumpHeight = 7.2
	end
end)

Once again this doesn't make sense to me as I'm pretty sure this should work.

2 comments

0

Hi can't you just go to game settings under world change the speed and jump height?? I don't understand what you are trying to make with this.

0

Sorry for the misunderstanding but I'm trying to make it where if they press a button they get to move but when they first join they are still

4 answers

✓ Accepted answer

It's because on the server they're still set to 0. The server is overwriting the clients when it updates them about how the game is supposed to be currently playing out since according to the server, they're still supposed to be unable to walk or jump. Clients themselves can't modify any physical information the server has so you have to have the client let the server know. You're gonna want to use RemoteEvents to tell the server when the player presses a button so the server itself can set them back to their correct speed.

2 comments

0

I just tried it and I don't know if it works yet because it doesn't even register the mousebutton1click function, I even put a print right after the function and nothing came out in the output. So it has something to do with the MouseButton1Click function.

0

I fixed it all I did was take the textbutton out the frame but still in the screengui and it works!

There is a wait in your local script next the wait for child in your humanoid variable

1 comment

0

There's nothing wrong about it

A few things here, you don't need all of that humanoid variable, and you don't need to check if the thing clicking is the localPlayer, it's a local script.

local localPlayer = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Enabled = false
	localPlayer.Character.Humanoid.WalkSpeed = 16
	localPlayer.Character.Humanoid.JumpHeight = 7.2
end)

1 comment

0

It still doesn't work

It also Happened to me while making a super speed script even I was using local scripts.

1 comment

0

I think it said trying to Index WalkSpeed with Nil?

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