Changing walkspeed with StarterCharacters

I recently tried to change the player’s walkspeed by accessing Humanoid through StarterCharacter using this code: Player.Character:FindFirstChild("Humanoid").WalkSpeed = ....

Here’s the full code if it’s part of the problem:

label = script.Parent.changelog
creds = script.Parent.creds
blur = game:GetService("Lighting").Blur
sgui = script.Parent.Parent
splayer = game:GetService("StarterPlayer")


script.Parent.Enabled = true

local Player = game:GetService("Players").LocalPlayer
repeat wait() until Player.Character

blur.Enabled = true
blur.Size = 25

sgui.Notification.Enabled = false

--splayer.CharacterWalkSpeed = 0
--splayer.CharacterJumpPower = 0
Player.Character:FindFirstChild("Humanoid").WalkSpeed = 0
Player.Character:FindFirstChild("Humanoid").JumpPower= 0

creds:TweenPosition(UDim2.new(0.5,0,0.196,0), "InOut", "Elastic", 1, true)
wait(3)

creds:TweenPosition(UDim2.new(1.4,0,0.196,0), "Out", "Elastic", 1, true)
wait(0.05)

label:TweenPosition(UDim2.new(0.05,0,0.196,0), "InOut", "Elastic", 1, true)

label.continue.MouseButton1Click:Connect(function()
	label:TweenPosition(UDim2.new(-0.4,0,0.196,0), "Out", "Elastic", 1, true)
	wait(0.1)

	for i = 1, 0, -1 do
		blur.Size = i
		wait(.5)
	end
	
	--splayer.CharacterWalkSpeed = 16
	--splayer.CharacterJumpPower = 50
	Player.Character:FindFirstChild("Humanoid").WalkSpeed = 16
	Player.Character:FindFirstChild("Humanoid").JumpPower = 50
	sgui.Notification.Enabled = true
end)

But basically when I click the button, it doesn’t change the walkspeed or jumppower to their original numbers.

1 Like

Try to use PlayerModule, like this:

local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

local Controls = PlayerModule:GetControls()

Controls:Disable()--Disable Controls
Controls:Enable()--Enable Controls

It says theres an infinite yield on WaitForChild"PlayerModule"

I can’t seem to get that error…

According to Studio, PlayerModule doesn’t exist in PlayerScripts:
image

Hm, for me it shows up, I don’t know why it isn’t there…
screenshotofstudio

Can you send a file copy of PlayerModule please?

Here, PlayerModuleTest - Copy.rbxl (21.7 KB)

Now that I have PlayerModules, the UI appears on startup (which didn’t happen before), but still can’t move the character:
https://i.gyazo.com/973a0a4d9887cc1c9fe8ad7185768734.mp4

Not sure why…
did you use Controls:Disable() in the beginning of the script?

Yeah, and then I enabled it at the end again:

label = script.Parent.changelog
creds = script.Parent.creds
blur = game:GetService("Lighting").Blur
sgui = script.Parent.Parent
splayer = game:GetService("StarterPlayer")
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

local Controls = PlayerModule:GetControls()

script.Parent.Enabled = true

local Player = game:GetService("Players").LocalPlayer
repeat wait() until Player.Character

blur.Enabled = true
blur.Size = 25

sgui.Notification.Enabled = false

Controls:Disable()--Disable Controls

creds:TweenPosition(UDim2.new(0.5,0,0.196,0), "InOut", "Elastic", 1, true)
wait(3)

creds:TweenPosition(UDim2.new(1.4,0,0.196,0), "Out", "Elastic", 1, true)
wait(0.05)

label:TweenPosition(UDim2.new(0.05,0,0.196,0), "InOut", "Elastic", 1, true)

label.continue.MouseButton1Click:Connect(function()
	label:TweenPosition(UDim2.new(-0.4,0,0.196,0), "Out", "Elastic", 1, true)
	wait(0.1)

	for i = 1, 0, -1 do
		blur.Size = i
		wait(.5)
	end
	
	Controls:Enable()--Enable Controls
	sgui.Notification.Enabled = true
end)

I think the problem is the for loop, it seems unnecessary, and I don’t think it lets code after it run…

It runs sgui.Notification.Enabled = true, and why is it unnecessary

It is unnecessary because it only runs once

It is meant to run once, when the player clicks the button on a gui that only appears when they join. If you have an alternative, I’ll listen.

You could just run it once, right?
Maybe not, but if not, why?

No the for loop is meant to make the blur have a gradual un-size, so it looks like the blur is fading away quickly.

but it only runs once, it goes from 1, to, 0, by an increment of 1,
Right?

Changing the Humanoid’s WalkSpeed only works using a Server Script.

If you’re using a Local Script then try creating a RemoteEvent that signals the server to change the WalkSpeed.

Hope this helps! :slight_smile: