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

Having multiple Local errors on this localscript?[Read script for more info]

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

2 comments

0

Delete that bottom part. What you do instead is check the GUI for ResetOnSpawn and set it equal to false.

0

@Horribils _Aedrovulf Thank you for the tip.

2 answers

✓ Accepted answer

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.

1 comment

0

Everything works but, loading doesn't work, well, I'll just remove it for now and maybe the assets will be fine.

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.

1 comment

0

I wanted a loading screen because I wanted the players who just join to let the assets and the things get a chance to load.

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