Script doesnt work for some reason?

My script below is completed and it should work. Though when I press Y, it doesn’t do anything. Literally nothing, I have checked the Output and nothing is there so I’m practically stuck in one place which I can’t get out of. I am trying to make the script change UIs so make frame 1 not visible and frame 2 visible

–variables
local uis = game:GetService(“UserInputService”)

–change channel
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Y and script.Parent.Parent.mainframe.Visible == false then
script.Parent.Visible = false
script.Parent.Parent.mainframe.Visible = true
end
end)

What are you trying to achieve?

To try and fix the script, to make it change GUI frames. It works on a different script

I cant tell what the issue is, there are no variables in this script so i cannot figure out whats wrong.

image

The reason could be that the frames dont load, or function correctly, you could fix this by using variables. START IMPLEMENTING VARIABLES INTO YOUR SCRIPTS!!!

local UIS = game:GetService("UserInputService")

local OnCallFrame = script.Parent
local GUI = OnCallFrame.Parent
local MainFrame = GUI:WaitForChild("mainframe")

UIS.InputBegan:Connect(function(input, gpe)
   if gpe then return end

   if input.KeyCode == Enum.KeyCode.Y and not MainFrame.Visible then
      OnCallFrame.Visible = false
      MainFrame.Visible = true
   end
end

Even that doesnt work… I am actually stuck right now

Is the frames transparency set to 0?

Yes, it is. I have a buttons script which can change the frames with a button and that works fine.

Try this instead then, if it doesnt work then its an issue with the frames. (or the script is disabled)

local UIS = game:GetService("UserInputService")

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

repeat wait() until Player.Character ~= nil

local RadioGui = PlayerGui.Radio
local OnCallFrame = RadioGui.oncallframe
local MainFrame = RadioGui.mainframe

UIS.InputBegan:Connect(function(input, gpe)
   if gpe then return end

   if input.KeyCode == Enum.KeyCode.Y and not MainFrame.Visible then
      OnCallFrame.Visible = false
      MainFrame.Visible = true
   end
end

Managed to fix it using a value. Don’t know how. Thanks for attempting to help though, much appreciated

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.