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

How can I make a GUI that allows custom walkspeed?

I am making a GUI and want to make a textbox to choose walkspeed

My script is game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = script.Parent.Text

Here's a view of studio: https://vgy.me/bZsqjk.png

2 comments

1

walkspeed is a float and you are setting it to a string?

0

Do tonumber(script.Parent.Text)

2 answers

The text of the TextBox is a string (text). You cannot just set it as the WalkSpeed. You need to turn the text into a number with a function called tonumber().

hum.WalkSpeed = tonumber(script.Parent.Text)

Note that this function returns nil if the number is invalid, so you may want to use a ternary statement like this, in order to prevent unnecessary errors:

hum.WalkSpeed = tonumber(script.Parent.Text) or hum.WalkSpeed

That way if tonumber() returns nil, it will set the WalkSpeed to the current WalkSpeed (so it will be like it has never changed)

3 comments

0

Actually setting a number value like walkspeed to nil will just set it to 0.

0

nil = 0, not the current walkspeed

0

Yea same thing. Op probably doesn't want the walkspeed to set to 0 whenever someone makes a typo

game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = tonumber(script.Parent.Text) did not work

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