Help with Speed Script(simple fix?)

Hi,

I need some help with a speed script, for some reason, the script doesn’t seem to change the player’s speed, to 50. The output keeps saying image

here is the (local)script:
image
image

You did not specify :GetPlayerFromCharacter(), but as you are using a localscript you can simply do local player = game.Players.LocalPlayer and for the character just do local player = game.Players.LocalPlayer.Character

1 Like

thanks, i’ll try it out, hope it works

Since this script is located in StarterGui, the right choice would be to use a local script. Method :GetPlayerFromCharacter() is only really useful when we need to get player from character server-side, so in this case, because it’s a local script, you can use Players.LocalPlayer to get the player.

local Players = game:GetService("Players")

local character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local defaultSpeed = humanoid.WalkSpeed -- default walkspeed

local SPRINT_SPEED = 25 -- set desired sprint speed

local sprint_on = false

--[[
	On each button activation, check what the script_on value is. I like to use this
	statement form:
	
	"condition" and "action" or "another action"
	
	The above statement is equivalent to:
	
	if (sprint_on) then
		humanoid.WalkSpeed = SPRINT_SPEED
	else
		humanoid.WalkSpeed = defaultSpeed
	end
]]
script.Parent.Activated:Connect(function()
	sprint_on = not sprint_on
	humanoid.WalkSpeed = sprint_on and SPRINT_SPEED or defaultSpeed
end)
1 Like

Thank you, for your help, but the issue has been solved. However, i will also take note of this