Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't the gui number changing?

Asked by 3 years ago
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

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 Sheepsee 2 — 3y
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'. SirGamezy 186 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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

0
hope I've helped you. tell me if anything is wrong Olimooseman -5 — 3y
0
thank you! this helped a lot Sheepsee 2 — 3y
0
youre welcome! Olimooseman -5 — 3y
Ad

Answer this question