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

Why isn't the gui number changing?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Number = game.StarterGui.ScreenGui.RadioNumb.Radio.Value
local textGui = script.Parent


local uis = game:GetService("UserInputService")
uis.InputEnded:connect(function(inst)
    if inst.KeyCode == Enum.KeyCode.E then
        Number = Number + 1
		textGui.Text = string(Number)
		print("work")
    end
end)
uis.InputEnded:connect(function(inst)
    if inst.KeyCode == Enum.KeyCode.Q then
        Number = Number - 1
		textGui.Text = string(Number)
		print("work")
    end
end)

I was trying to make a radio as a game, with music. I want it to work sorta like a radio. The gui thing looks like this

ScreenGui -> TextGui:RadioNumb -> IntValue:Radio, LocalScript:changeStation

2 comments

0

21:25:28.994 - Players.Sheepsee.PlayerGui.ScreenGui.RadioNumb.changeStation:18: attempt to call a table value - the error if you guys need it

0

In line 11, I don't think you need the word 'string' before 'Number'. Since Number is a variable, you can simply use 'Number'.

1 answer

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Number = game.StarterGui.ScreenGui.RadioNumb.Radio.Value
local textGui = script.Parent


local uis = game:GetService("UserInputService")
uis.InputEnded:Connect(function(inst)
    if inst.KeyCode == Enum.KeyCode.E then
        Number = Number + 1
        textGui.Text = tostring(Number)
        print("work")
    elseif inst.KeyCode == Enum.KeyCode.Q then
        Number = Number - 1
        textGui.Text = tostring(Number)
        print("work")
    end
end)

tostring(), not string()

also change connect to Connect

and you can use elseif instead of two ifs

3 comments

0

hope I've helped you. tell me if anything is wrong

0

thank you! this helped a lot

0

youre welcome!

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