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

Why wont this script I duplicated work when it worked before?

I made a script that opened and closed a gui every time you clicked a button, it worked. I needed the same script for a different button, so I duplicated the script and put it in a different button and made a few changes to make a different gui appear. For some reason however, the copy of the script wont work, and it gives me an error that says:

CreateTerritoryGui is not a valid member of PlayerGui "Players.Paczki_TCBC.PlayerGui"

(CreateTerritoryGui is the gui I'm trying to make appear, and Paczki_TCBC is my username.)

here is the script that did work:

local Or = 1
local button = script.Parent
local editor = button.Parent.Parent.Editor
editor.Enabled = false

button.MouseButton1Up:Connect(function()
	Or = Or * -1
	if Or == -1 then
		editor.Enabled = true
	elseif Or == 1 then
		editor.Enabled = false
	
	end
end)

and here is the one that did not work:

local choice = 1
local button = script.Parent
local editor = button.Parent.Parent.CreateTerritoryGui
editor.Enabled = false

button.MouseButton1Up:Connect(function()
	choice = choice * -1
	if choice == -1 then
		editor.Enabled = true
	elseif choice == 1 then
		editor.Enabled = false
	
	end
end)

3 comments

0

This could be because the script is trying to find CreateTerritoryGui before it has loaded in try replacing button.Parent.Parent.CreateTerritoryGui with button.Parent.Parent:WaitForChild("CreateTerritoryGui")

0

thanks everyone but i figured it out on my own

0

fyi, there is *=, +=, %=, -=, /=, ..=, operators which to the same thing as value = value + value2

2 answers

Make sure there is a thing called CreateTerritoryGui (script.Parent.Parent.Parent.CreateTerritoryGui)

1 comment

0

there is

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