Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

0
Delete that bottom part. What you do instead is check the GUI for ResetOnSpawn and set it equal to false. TiredMelon 405 — 5y
0
@Horribils _Aedrovulf Thank you for the tip. mudathir2007 157 — 5y

2 answers

Log in to vote
0
Answered by
Z_DC 104
5 years ago

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.

0
Everything works but, loading doesn't work, well, I'll just remove it for now and maybe the assets will be fine. mudathir2007 157 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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.

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. mudathir2007 157 — 5y

Answer this question