What do you want to achieve?
I was trying to make when if textbutton is visible then the gui is not enable
What is the issue?
The If statement doesent seem to work
local Events = game.ReplicatedStorage.MiscEvents.GuiEvent
local timer = script.parent
local gui = script.parent.parent
local button = game.StarterGui.RadioGui.ImageButton.Frame.TextButton
Events.OnClientEvent:Connect(function()
gui.Enabled = true
for i = 10,0,-1 do
timer.Text = i
end
timer.Text = i
end)
if button.Visible == true then
gui.Enabled = false
end
i have change the script but still it doesent work and also messed up the countdown i think i may have done it wrong?
local Events = game.ReplicatedStorage.MiscEvent.GuiEvent
local Timer = script.Parent
local gui = script.Parent.Parent
local players = game.Players.LocalPlayer
local Radio = players.PlayerGui:WaitForChild("RadioGui")
local button = Radio.ImageButton.Frame.TextButton
local plgui = players.PlayerGui:WaitForChild("CountdownRadio")
Events.OnClientEvent:Connect(function()
gui.Enabled = true
for i = 10,0,-1 do
Timer.Text = i
end
Timer.Text = ""
end)
if button.Visible == true then
plgui.Enabled = false
end
in proximity prompt i put a script then fireallclient then i used that event in a local script under a countdown gui that if another gui that is visible, which the other gui also use onclientevent, so i want the countdown would end if the other gui is turned visible, yes im making the gui disabled
Nope, this code will only run ONCE when the script is added into the player, and this part of the code will never run again, its not listening, not connected to any event
if button.Visible == true then
gui.Enabled = false
end
oh that part, i thought you meant the countdown, yeah i dont know, but my goal is when the RadioGui textbutton is visible then the CountdownGui disabled, the radio gui is using onclientevent which it only be visible when the proximity prompt gets triggered which i fireallclient, so radiogui would appear but the textbutton didnt until i click another button,then it will be visible, so when it is visible the countdowngui will be disabled
Im sorry I cant understand your explanation.
The code you are showing does this:
When script is added into the player, checks button.Visible, if true, proceeds to disable the gui
And it has a listener, made by OnClientEvent, waiting signal from server to enable gui, then a loop to update a text with a countdown.
And thats all your script does
local Events = game.ReplicatedStorage.MiscEvents.GuiEvent
local timer = script.parent
local gui = script.parent.parent
local button = game.StarterGui.RadioGui.ImageButton.Frame.TextButton
Events.OnClientEvent:Connect(function()
gui.Enabled = true
for i = 10,0,-1 do
timer.Text = i
end
--timer.Text = i
end)
if button.Visible == true then
warn("IM HERE!")
gui.Enabled = false
end
Yeah, its what I said, the if statement only run once, its not connected to any event in order to happen again.
You tested the code and found the warn that proves it runs at least once?
If it runs once, then now place the if statement into a function connected to an event when you want to disable the gui when button visibility becomes true.
(I guess, cause I dont understand yet what is the goal)
Make the visibility of the button to control the gui visibility on property changed? or handle it by using the remote.OnClientEvent() (?)