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

Problems with GUI script?

Asked by
F_lipe 135
10 years ago

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!

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 NinjoOnline 1146 — 10y
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. Perci1 4988 — 10y
0
It's in a LocalScript. F_lipe 135 — 10y

2 answers

Log in to vote
3
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

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.

Ad
Log in to vote
0
Answered by
F_lipe 135
10 years ago

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.

0
There is a comment feature, use it. Perci1 4988 — 10y
0
It would be quite hard to post my code in the comment bar would it not? F_lipe 135 — 10y
0
Perhaps replace "script.Parent.Parent.Parent.Parent.Parent" to "game.Players.LocalPlayer" Redbullusa 1580 — 10y
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" Redbullusa 1580 — 10y
View all comments (2 more)
0
"if Opened == true then Opened = false" .. etc Redbullusa 1580 — 10y
0
I'll try all this and I already fixed it to be 'game.Players.LocalPlayer" I'll get back to you. F_lipe 135 — 10y

Answer this question