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

I've updated the script for the radio, now it stopped working. Help?

Asked 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
        if Number ~= 101.1 then         
            Number = Number + 0.1
            textGui.Text = tostring(Number)
            print("work")
    elseif inst.KeyCode == Enum.KeyCode.Q then
        if Number ~= 99.9 then       
            Number = Number - 0.1
            textGui.Text = tostring(Number)
            print("work")
        end
    end
end)
0
I tried to make it limited to a certain amount of numbers, but then it stopped working. Sheepsee 2 — 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 = script.Parent.Radio.Value
local textGui = script.Parent


local uis = game:GetService("UserInputService")
uis.InputEnded:Connect(function(inst)
    if inst.KeyCode == Enum.KeyCode.E and Number < 101.1  then   
            Number = Number + 0.1
            textGui.Text = tostring(Number)
            print("work")
    elseif inst.KeyCode == Enum.KeyCode.Q and Number > 99.9 + 0.1 then -- without +0.1 it would be able to have a 99.8 value, don't think you want that
            Number = Number - 0.1
            textGui.Text = tostring(Number)
            print("work")
    end
end)
0
Thank you again! You're being really helpful with this :D Sheepsee 2 — 3y
0
You're welcome! :) Olimooseman -5 — 3y
0
Now it starts to go over the top number, what happened? Sheepsee 2 — 3y
0
I see why. You're picking up the value from the startergui, not from the playersgui, that way it wont update for the player. Could you tell me where you script is located so I could help you? Olimooseman -5 — 3y
View all comments (6 more)
0
StarterGui -> ScreenGui -> TextGui:RadioNumb -> IntValue:Radio, LocalScript:changeStation Sheepsee 2 — 3y
0
Updated my awnser, now it fully works (also tested it ingame)! Olimooseman -5 — 3y
0
fixed it, forgot to make as code block Olimooseman -5 — 3y
0
Thank you for all your help! You're the only reason i can make this "game" (it's more of a vibe game thing) Sheepsee 2 — 3y
0
you're welcome! :D Good luck with your "game" xD Olimooseman -5 — 3y
0
btw I got the name wrong, its "Radio", not "RadioNumb". My bad Olimooseman -5 — 3y
Ad

Answer this question