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

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

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)

1 comment

0

I tried to make it limited to a certain amount of numbers, but then it stopped working.

1 answer

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)

10 comments

0

Thank you again! You're being really helpful with this :D

0

You're welcome! :)

0

Now it starts to go over the top number, what happened?

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?

0

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

0

Updated my awnser, now it fully works (also tested it ingame)!

0

fixed it, forgot to make as code block

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)

0

you're welcome! :D Good luck with your "game" xD

0

btw I got the name wrong, its "Radio", not "RadioNumb". My bad

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