Deactivating a GUI from another Script

Hi guys,

I have a problem concerning my LoadingScreen.
Basically what I want is that another GUI is getting deactivated while the LoadingScreen is doing his thing. In my example, I want the RadioSystem GUI to get invisible but it don’t works. I tried using while loops, couroutines, making the frame visible to false and disabling the hole ScreenGui. I don’t know what I can do more.

Here’s the local script:

function RadioDeactivate()
	if game:GetService("StarterGui"):FindFirstChild("RadioSystem") then --Checking if the GUI exists. Until here, it works
		game:GetService("StarterGui").RadioSystem.Enabled = false --Here, the script doesn't work and the GUI is still visible
	end
end

function RadioActivate()
	if game:GetService("StarterGui"):FindFirstChild("RadioSystem") then --Checking if the GUI exists. Until here, it works
		game:GetService("StarterGui").RadioSystem.Enabled = true --Enabling the GUI 
	end
end

while value == true do
	BodyAnchor() --Unimportant function to anchor the player
	RadioDeactivate() --Here I want to deactivate the GUI
	AssetL.TextColor3 = Color3.new(255, 255, 255)
	AssetL.Text = "Lade Inhalte ."
	wait(1)
	AssetL.Text = "Lade Inhalte . ."
	wait(1)
	AssetL.Text = "Lade Inhalte . . ."
	wait(1)
	if game.ContentProvider.RequestQueueSize == 0 then
		value = false
		value2 = false
		wait(1)
		AssetL.Text = "Geladen!"
		AssetL.TextColor3 = Color3.new(0.113725, 0.870588, 0)
		wait(2)
		BodyAnchor() --Making the player movable again, also unimportant for now
		RadioActivate() --Here I want to toggle the GUI on again
		script.Parent.Parent:Destroy()
	end
end

Yeap so that’s it!

StarterGui means if you join to the game the gui will appear at your gui folder in the player object. You should close the radio gui from gui folder in the player object not the script in the starter gui.

Use this:

local Player = game:GetService("Players").LocalPlayer

function RadioDeactivate()
	if Player:WaitForChild("PlayerGui"):FindFirstChild("RadioSystem") then --Checking if the GUI exists. Until here, it works
		Player:WaitForChild("PlayerGui").RadioSystem.Enabled = false --Here, the script doesn't work and the GUI is still visible
	end
end

function RadioActivate()
	if Player:WaitForChild("PlayerGui"):FindFirstChild("RadioSystem") then --Checking if the GUI exists. Until here, it works
		Player:WaitForChild("PlayerGui").RadioSystem.Enabled = true --Enabling the GUI 
	end
end

while value == true do
	BodyAnchor() --Unimportant function to anchor the player
	RadioDeactivate() --Here I want to deactivate the GUI
	AssetL.TextColor3 = Color3.new(255, 255, 255)
	AssetL.Text = "Lade Inhalte ."
	wait(1)
	AssetL.Text = "Lade Inhalte . ."
	wait(1)
	AssetL.Text = "Lade Inhalte . . ."
	wait(1)
	if game.ContentProvider.RequestQueueSize == 0 then
		value = false
		value2 = false
		wait(1)
		AssetL.Text = "Geladen!"
		AssetL.TextColor3 = Color3.new(0.113725, 0.870588, 0)
		wait(2)
		BodyAnchor() --Making the player movable again, also unimportant for now
		RadioActivate() --Here I want to toggle the GUI on again
		script.Parent.Parent:Destroy()
	end
end

Yeah your right, I didn’t thought about this. Thank you!

1 Like

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