I have a leaderstats called Max Speed, and in the settings menu of my game I'm trying to code a script which will allow players to type in an amount equal to or below their Max speed and have it change the players speed. Is there a way to do this, I'm quite new to scripting and I can't figure out a way to get this to work. Any help would be appreciated, thank you.
COMMUNITY QUESTION
How do I make a text box change the players speed, with a max speed?
1 answer
You can do this as a local script:
local TextBox = script.Parent.TextBox
game:GetService("UserInputService").InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Return and game:GetService("UserInputService"):GetFocusedTextBox() == TextBox then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = tonumber(TextBox.Text)
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
