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)
`
It's designed to make a Text button display a number every time an s or w key is pressed, but I cannot make the script work with the button, can you help fix this?
i found it when you did
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
the if input.KeyCode.Name=="W"then
should be if inputObject.KeyCode.Name=="W"then
you forgot inputObject
I'm not sure about this one, but I think that the problem with this is that you used a number value in a string value. If this is not the problem and the code is put into a normal Script, just change it to a LocalScript like TheDeadlyPanther said.
This would be the solution:
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
I'm neither sure about whether it will work nor have I tested it, but I still hope it helps you. :)