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

I get the error Gui is not a member of PlayerGui, but not in studio. Can anybody help?

Hey, I'm working on a Floor Is Lava game, yes I know but it's just a starter game as I'm learnng LUA. I've gone off the disaster script (oh no!) but I've actually redone it a bit and have converted and updated it to be more modern like (guis and stuff), the only thing, everytime I join the game get the error "Times is not a member of PlayerGui", and the game is FE enabled, however I tried without FE and still no luck.

It works completely fine in Studio, please help. Thanks.

Here is my game script

disasters = {"DoubleTrouble"}


countdownTime = 30 
disasterTime = 40 -- not needed

countdownMessage = "%s"
disasterMessage = "%s" -- not needed


items = {}
leaderboard = game.Workspace:findFirstChild("BTS Leaderboard")
local w = game.Workspace:getChildren()
for i=1,#w do
	if w[i].Name == "leaderboard" and w[i]:findFirstChild("running") ~= nil and w[i]:findFirstChild("points") ~= ni then
		leaderboard = w[i]
	end
end
for i=1,#disasters do
	local item = game.Lighting:findFirstChild(disasters[i])
	if item ~= nil then
		item.Parent = nil
		table.insert(items, item)
	else
		print("Error! ", disasters[i], " was not found!")
	end
end

function chooseDisaster()
	return items[math.random(#items)]
end

function sethint(text)
	local players = game.Players:GetChildren()
	for i,v in pairs(players) do
		print(v)
		if (v.PlayerGui.Timers.Timer ~= nil) then
			v.PlayerGui.Timers.Timer.Text = text
		end
	end
end

function lavaRising()
	local players = game.Players:GetChildren()
for i, v in pairs(players) do
	if (v.PlayerGui.Timers.Timer ~= nil) then
		 v.PlayerGui.Timers.BigLabel.Text = "The Lava Is Rising In"
                v.PlayerGui.Timers.Timer.Text = "10"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "9"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "8"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "7"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "6"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "5"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "4"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "3"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "2"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "1"
                wait(1)
                v.PlayerGui.Timers.Timer.Text = "0"
                wait(1)
	end
end
end

function gameEnd()
	local players = game.Players:GetChildren()
for i, v in pairs(players) do
	if (v.PlayerGui.Timers.Timer ~= nil) then
		 v.PlayerGui.Timers.BigLabel.Text = "Intermission"
	end
end
end

function timeLeft()
	local players = game.Players:GetChildren()
	for i, v in pairs(players) do
		if (v.PlayerGui.Timers.Timer ~= nil) then
			v.PlayerGui.Timers.Timer.Text = "30"
			v.PlayerGui.Timers.BigLabel.Text = "Time Left"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "29"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "28"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "27"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "26"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "25"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "24"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "23"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "22"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "21"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "20"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "19"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "18"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "17"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "16"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "15"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "14"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "13"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "12"
			wait(1)
			v.PlayerGui.Timers.Timer.Text = "11"
			wait(1)
            v.PlayerGui.Timers.Timer.Text = "10"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "9"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "8"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "7"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "6"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "5"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "4"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "3"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "2"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "1"
            wait(1)
            v.PlayerGui.Timers.Timer.Text = "0"
            wait(1)
		end
	end
end

function countdown(time)
	sethint(string.format(countdownMessage, tostring(time)))
	while (time > 0) do
		wait(1)
		time = time - 1
		sethint(string.format(countdownMessage, tostring(time)))
	end
	return true
end

wait(10)
while true do
	countdown(countdownTime)

	if leaderboard ~= nil and leaderboard:findFirstChild("running") and leaderboard:findFirstChild("points") then -- For use with my BTS leaderboard.
		leaderboard.points.Value = 15
		leaderboard.running.Value = true
	end

	local m = chooseDisaster():clone()

    if disasterMessage ~= nil then
        local players = game.Players:GetChildren()
        for i,v in pairs(players) do
            if (v.PlayerGui.Timers.Timer ~= nil) then
                v.PlayerGui.Timers.Timer.Text = string.format(disasterMessage, m.Name)
                v.PlayerGui.Timers.BigLabel.Text = "Map Chosen!"
                wait(3)
            end
        end
    end

	m.Parent = game.Workspace
	m:makeJoints()
	lavaRising()
	timeLeft()
	m:remove()
	gameEnd()

	if leaderboard ~= nil then -- For use with the bts leaderboard.
		leaderboard.running.Value = false
	end
end

2 comments

0

As for the wait(1), then change Text that is just a placeholder until I can figure out the current issue. Thanks.

0

Are you sure your error is correctly typed, because I don't see "Times" being mentioned in this script.

2 answers

The problem you have is that you must use p.PlayerGui:WaitForChild("Timers")

If this helped please approve this answer! Thanks!

1 comment

0

i have come into this problem meny times when scripting and the easy fix is just to use :WaitForChild()

I did some tweaking, here and there, Like for example, you used depricated functions, You didn't use for loops(Makes your code shorter and saves a lot of time), Plus there is a big diffrence 196 and 112 lines of code You spelled nil incorrect, And I also recommend WaitForChild instead of FindFirstChild

disasters = {"DoubleTrouble"}


countdownTime = 30 
disasterTime = 40 -- not needed

countdownMessage = "%s"
disasterMessage = "%s" -- not needed


items = {}
leaderboard =	workspace:WaitForChild("BTS Leaderboard")
local w = workspace:GetChildren() -- Its not getChildren() its GetChildren()
for i=1,#w do
    if w[i].Name == "leaderboard" and w[i]:WaitForChild("running") ~= nil and w[i]:WaitForChild("points") ~= nil then -- you did ni instead of nil
        leaderboard = w[i]
    end
end
for i=1,#disasters do
    local item = game.Lighting:WaitForChild(disasters[i])
    if item ~= nil then
        item.Parent = nil -- Why make item.Parent nil??
        table.insert(items, item)
    else
        print("Error!  "..disasters[i] .. " was not found!") -- You don't use a comma to connect strings, you use two dots to connect strings
    end
end

function chooseDisaster()
    return items[math.random(0,#items)] -- math.random has two arguments minimum value and a maximum value
end

function sethint(text)
    local players = game.Players:GetChildren()
    for i,v in pairs(players) do
        print(v)
        if v.PlayerGui.Timers.Timer ~= nil then
            v.PlayerGui.Timers.Timer.Text = text
        end
    end
end

function lavaRising()
    local players = game.Players:GetChildren()
for i, v in pairs(players) do
    if v.PlayerGui.Timers.Timer ~= nil then
         v.PlayerGui.Timers.BigLabel.Text = "The Lava Is Rising In"
         for lavaRise = 10,0,-1 do  v.PlayerGui.Timers.Timer.Text end -- For loops make your games proffesional and makes things easier to read
    end
end
end

function gameEnd()
    local players = game.Players:GetChildren()
for i, v in pairs(players) do
    if v.PlayerGui.Timers.Timer ~= nil then
         v.PlayerGui.Timers.BigLabel.Text = "Intermission"
    end
end
end

function timeLeft()
    local players = game.Players:GetChildren()
	for i, v in pairs(players) do
	 v:WaitForChild("PlayerGui"):WaitForChild("Timers").BigLabel.Text = "Time Left"
        if v:WaitForChild("PlayerGui").Timers.Timer ~= nil then
        for i = 30,0,-1 do v.PlayerGui.Timers.Timer.Text = i wait(1) end -- For loops are make your game more proffesional and it'll be more easier to read   
        end
    end
end

function countdown(time)
    sethint(string.format(countdownMessage, tostring(time)))
    while time > 0 do
        wait(1)
        time = time - 1
        sethint(string.format(countdownMessage, tostring(time)))
    end
    return true
end

wait(10)
while true do
    countdown(500)

    if leaderboard ~= nil and leaderboard:WaitForChild("running") and leaderboard:WaitForChild("points") then -- For use with my BTS leaderboard.
        leaderboard.points.Value = 15
        leaderboard.running.Value = true
    end

    local m = chooseDisaster():Clone() -- Its not clone() its Clone()

    if disasterMessage ~= nil then
        local players = game.Players:GetChildren()
        for i,v in pairs(players) do
            if (v.PlayerGui.Timers.Timer ~= nil) then
                v.PlayerGui.Timers.Timer.Text = string.format(disasterMessage, m.Name)
                v.PlayerGui.Timers.BigLabel.Text = "Map Chosen!"
                wait(3)
            end
        end
    end
    m.Parent = workspace 
    m:makeJoints()
    lavaRising()
    timeLeft()
    m:remove()
    gameEnd()
    if leaderboard ~= nil then -- For use with the bts leaderboard.
        leaderboard.running.Value = false
    end
end

Hopefully this fixed your script and made it more efficient

5 comments

0

Still not working, works in studio but not roblox player (Fe enabled)

0

Oh... sorry

0

I see

0

What you needed to do is get another script and call the remote event remoteEvent:FireAllClients()

0

Get a remote event that fires the server then get the local script and fire all of the clients

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