I have a rather simple code that I need to be displayed into a text button, this is it so far.
number = 164
while number >164 or <2404
if pressing w then...number=number +32
elseif pressing s then number =number -32
I need the numbers to change and be displayed in a text button.
You want to use the InputBegan
and InputEnded
events of UserInputService
to tell when keys are being pressed and a TextButton
object to display a number in a text button.
A number that is either greater than 164 or less than 2404 is every number.
local number=164 local TextButton=Instance.new("TextButton",Instance.new("ScreenGui",game.Players.LocalPlayer:WaitForChild("PlayerGui"))) TextButton.Text=number local inputservice=game:GetService("UserInputService") local wdown,sdown=false,false inputservice.InputBegan:connect(function(input) if input.KeyCode.Name=="W"then wdown=true while wdown do wait(.1) number=number+32 TextButton.Text=number end elseif input.KeyCode.Name=="S"then sdown=true while sdown do wait(.1) number=number-32 TextButton.Text=number end end end) inputservice.InputEnded:connect(function(input) if input.KeyCode.Name=="W"then wdown=false elseif input.KeyCode.Name=="S"then sdown=false end end)