i have a script for a game that im making but when i try to test it it doesnt work,
if wframe1.Visible == true and wframe4.Visible == true and wframe7.Visible == true then --when i replaced the ==true values with = false, it worked but not as intended--
script.Parent.Stick.Visible = true
script.Parent.Stick.MouseButton2Click:Connect(function()
script.Parent.Stick.Visible = false
game.Workspace.Stick.Value = game.Workspace.Stick.Value + 1
game.Workspace.Wood.Value = game.Workspace.Wood.Value - 3
wframe1.Visible = false
wframe4.Visible = false
wframe7.Visible = false
end)
end
Can you show us the output when both the true and false values are used? Also, you should implement s few prints in your script to check if the code even reaches that point.
Nice, in that case make sure that you’re referencing your gui through the player’s playerGui, as at runtime, the gui gets replicated into playerGui, and only there will it update.
What I would do to try and debug this, is add a print like so;
print(wframe1, wframe4, wframe7)
In the output this should print the instance and clicking them will bring you to the instance in the explorer. Here you can check to see if your variables are set up correctly. If this does not clarify anything, please share more code and screenshots so we can see where the issue resides.
im thinking the issue is because i have GuiCollisionService. and i dont think it registers, like for example i have a gui that if another gui touches it, it becomes visible
yep just tested it, if i have the gui visible from the start its all good. the gui collision service kinda breaks some things. i dont know how to fix it
Post attempt #2:
I might see where it goes wrong.
Your code goes as follows:
if <wframe.Visible == false conditions> then
script.Parent.Stick.Visible = true
script.Parent.Stick.MouseButton2Click:Connect(function()
<code>
end)
end
Code runs from top to bottom, line by line, so what it is doing now is as soon as there is a change in wframe.Visible and all the conditions are met, it will continue. Then it hits the MouseButton2Click. Is the mouse button not being clicked the millisecond after the wframe conditions are passed, then it will count as a no and break the code. Instead, swap them around, since the timeframe of a buttonclick is not constant, whereas the wframe visiblity is.
script.Parent.Stick.MouseButton2Click:Connect(function()
print(wframe1.Visible, wframe4.Visible, wframe7.Visible) --//debugging purposes only, to check if conditions are equal to the conditions needed to be met
if wframe1.Visible == false and wframe4.Visible == false and wframe7.Visible == false then
<code>
end
end)
If this works, I do not know yet, but this will at the least run the code in the box.