This script errors are a bit complex.. Part of this doesn't work at all, part of it only studio and not normal game, and part of it works both. I want all of them to work at least just in normal game.
-- Script is Local Script -- local plr = game.Players.LocalPlayer local house = plr.PlayerGui.GameChooseGUI.Frame local t = plr.PlayerGui.GameChooseGUI.Frame.PlayButton.Text debounce = false -- This below only works on studio -- script.Parent.Text = "LOADING." wait(1) script.Parent.Text = "LOADING.." wait(1) script.Parent.Text = "LOADING..." wait(1) script.Parent.Text = "LOADING." wait(1) script.Parent.Text = "LOADING.." wait(1) script.Parent.Text = "LOADING..." wait(1) script.Parent.Text = "LOADING." wait(1) script.Parent.Text = "LOADING.." wait(1) script.Parent.Text = "LOADING..." wait(1) script.Parent.Text = "PLAY NOW" -- This below is the only one that works on studio AND on game -- script.Parent.MouseButton1Click:Connect(function() plr.PlayerGui.GameChooseGUI.Frame.Visible = false plr.TeamColor = BrickColor.new("Bright red") debounce = true end) -- This below down't work both on studio or on game -- -- What this mess is below is I'm trying to make it so that the GUI only appears once so if the player dies it won't come again. if debounce == true then while wait() do if house.Visible == true then house.Visible = false end end end
Okay, let's try fixing this.
In order to fix the first part, you must utilize the WaitForChild method of the Instance objects in order to make sure those objects are actually in the player already and didn't either fail to load in or loaded in right after the script.
local plr = game.Players.LocalPlayer local house = plr.PlayerGui:WaitForChild("GameChooseGUI").Frame local t = house.PlayButton.Text local debounce = false
The second part that doesn't work would be fixed if instead of doing what you did, you let the GUI destroy itself after it is done. Maybe something like this:
script.Parent.MouseButton1Click:Connect(function() plr.PlayerGui.GameChooseGUI.Frame.Visible = false plr.TeamColor = BrickColor.new("Bright red") debounce = true house:Destroy() end)
And remove the last part.
Don't really know why you'd want to implement a loading screen like that. Also you need to wait for the gui and it's children load with :WaitForChild().
script.Parent.MouseButton1Click:Connect(function() plr.PlayerGui.GameChooseGUI.Frame.Visible = false plr.TeamColor = BrickColor.new("Bright red") debounce = true end) while wait() do if house.Visible and debounce then house.Visible = false end end
If that doesn't work then check if another script has overwritten the event.