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

EscolhaTimes is not a valid member of PlayerGui?

local sp = script.Parent

local RemoteEvent = game.ReplicatedStorage.MudarTime

local PrimeiraVez = true

local EscolhaTimesGUI = sp.EscolhaTimes
local EscolhaTimesFrame = sp.EscolhaTimes:WaitForChild("Frame")
local MudarDeTimeGUI = sp.MudarDeTimeGUI

local MORADOR = "White"
local POLICIA = "Dark blue"
local ROTA = "Black"
local CV = "Really red"
local PCC = "Crimson"

RemoteEvent:FireServer(BrickColor.new(MORADOR))

MudarDeTimeGUI.Enabled = false

EscolhaTimesFrame.BotaoPM.MouseButton1Click:connect(function()
	if PrimeiraVez then
		RemoteEvent:FireServer(BrickColor.new(POLICIA))
		EscolhaTimesGUI.Enabled = false
		MudarDeTimeGUI.Enabled = true
		
		PrimeiraVez = false
	end
end)

EscolhaTimesFrame.BotaoROTA.MouseButton1Click:connect(function()
	if PrimeiraVez then
		RemoteEvent:FireServer(BrickColor.new(ROTA))
		EscolhaTimesGUI.Enabled = false
		MudarDeTimeGUI.Enabled = true
		
		PrimeiraVez = false
	end
end)

EscolhaTimesFrame.BotaoCV.MouseButton1Click:connect(function()
	if PrimeiraVez then
		RemoteEvent:FireServer(BrickColor.new(CV))
		EscolhaTimesGUI.Enabled = false
		MudarDeTimeGUI.Enabled = true
		
		PrimeiraVez = false
	end
end)

EscolhaTimesFrame.BotaoPCC.MouseButton1Click:connect(function()
	if PrimeiraVez then
		RemoteEvent:FireServer(BrickColor.new(PCC))
		EscolhaTimesGUI.Enabled = false
		MudarDeTimeGUI.Enabled = true
		
		PrimeiraVez = false
	end
end)

sp.MudarDeTimeGUI.Frame.TextButton.MouseButton1Click:connect(function()
		RemoteEvent:FireServer(BrickColor.new(MORADOR))
		EscolhaTimesGUI.Enabled = true
		MudarDeTimeGUI.Enabled = false
		
		PrimeiraVez = true
end)

my script of the error, being that before it did not give.

1 answer

Your GUI's havent been loaded in. Always use Instance:WaitForChild. Edited script!

local sp = script.Parent

local RemoteEvent = game.ReplicatedStorage.MudarTime

local PrimeiraVez = true

local EscolhaTimesGUI = sp:WaitForChild("EscolhaTimes") -- wait for child!!
local EscolhaTimesFrame = sp.EscolhaTimes:WaitForChild("Frame")
local MudarDeTimeGUI = sp:WaitForChild("MudarDeTimeGUI") -- wait for child!!

local MORADOR = "White"
local POLICIA = "Dark blue"
local ROTA = "Black"
local CV = "Really red"
local PCC = "Crimson"

RemoteEvent:FireServer(BrickColor.new(MORADOR))

MudarDeTimeGUI.Enabled = false

EscolhaTimesFrame.BotaoPM.MouseButton1Click:connect(function()
    if PrimeiraVez then
        RemoteEvent:FireServer(BrickColor.new(POLICIA))
        EscolhaTimesGUI.Enabled = false
        MudarDeTimeGUI.Enabled = true

        PrimeiraVez = false
    end
end)

EscolhaTimesFrame.BotaoROTA.MouseButton1Click:connect(function()
    if PrimeiraVez then
        RemoteEvent:FireServer(BrickColor.new(ROTA))
        EscolhaTimesGUI.Enabled = false
        MudarDeTimeGUI.Enabled = true

        PrimeiraVez = false
    end
end)

EscolhaTimesFrame.BotaoCV.MouseButton1Click:connect(function()
    if PrimeiraVez then
        RemoteEvent:FireServer(BrickColor.new(CV))
        EscolhaTimesGUI.Enabled = false
        MudarDeTimeGUI.Enabled = true

        PrimeiraVez = false
    end
end)

EscolhaTimesFrame.BotaoPCC.MouseButton1Click:connect(function()
    if PrimeiraVez then
        RemoteEvent:FireServer(BrickColor.new(PCC))
        EscolhaTimesGUI.Enabled = false
        MudarDeTimeGUI.Enabled = true

        PrimeiraVez = false
    end
end)

sp.MudarDeTimeGUI.Frame.TextButton.MouseButton1Click:connect(function()
        RemoteEvent:FireServer(BrickColor.new(MORADOR))
        EscolhaTimesGUI.Enabled = true
        MudarDeTimeGUI.Enabled = false

        PrimeiraVez = true
end)

Please mark this as a solution if this helps! Metatable out!

2 comments

0

applause

0

@TTChaos is this wrong?

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