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

Problems with GUI script?

Okay so this is just some basic gui stuff but I ran into a error.

Here's what I have so far:

local Player = script.Parent.Parent.Parent.Parent.Parent
local Opened = Player.PlayerGui.GameBeta.HoldingFrame.Alliances.Opened
function onMouseButton1Down()
	script.Disabled = true
	 if Opened.Value == true then
		Opened.Value = false
		print("Closed")		
	elseif Opened == false then
		Opened.Value = true
		print("Opened")				 
	end
 script.Disabled = false
end

script.Parent.MouseButton1Down:connect(onMouseButton1Down)

I am using a bool value I know that. I can't seem to find the error here currently all I want it to do is print in the output.

Thank you!

3 comments

1

the answer below is correct as you are disabling the script before it can run the code. Just remove that and you should be fine

0

Make sure this is a LocalScript. Server scripts don't run inside the player. If it is a LocalScript, the proper method of getting the player is game.Players.LocalPlayer.

0

It's in a LocalScript.

2 answers

Remove script.Disabled = true, as it stops your script from running, therefore stopping your function from doing anything. Remove script.Disabled = false also, because it is redundant.

I am actually still having trouble,

script.Disabled is removed and I have this

local Player = script.Parent.Parent.Parent.Parent.Parent
local Opened = Player.PlayerGui.GameBeta.HoldingFrame.Leaderboard.Opened
function onMouseButton1Down()
	 if Opened.Value == true then
		Opened.Value = false
		print("Closed")		
	elseif Opened == false then
		Opened.Value = true
		print("Opened")				 
	end
end

script.Parent.MouseButton1Down:connect(onMouseButton1Down)

Still not printing anything into the output.

6 comments

0

There is a comment feature, use it.

0

It would be quite hard to post my code in the comment bar would it not?

0

Perhaps replace "script.Parent.Parent.Parent.Parent.Parent" to "game.Players.LocalPlayer"

1

If the script still doesn't work, maybe set the "Opened" variable into an actual boolean value in the script rather than outside of it? "local Opened = true"

0

"if Opened == true then Opened = false" .. etc

0

I'll try all this and I already fixed it to be 'game.Players.LocalPlayer" I'll get back to you.

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