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

How do i fix this script? It doesnt say an error message but it's like the script isnt even there...

Asked by 4 years ago
Edited by royaltoe 4 years ago

Hierarchy:

> game
>   StarterGui
>           SurfaceGui
>                   TextButton
>                           LocalScript

Script:

local label = game.StarterGui.ScreenGui.TextLabel
local button = script.Parent

button.MouseButton1Click:Connect(function()
    if label.Visible == true then
        label.Visible = false

elseif label.Visible == false then
    label.Visible = true
    end
end)
0
where is the local script? jorcorrs 76 — 4y
0
SurfaceGui's aren't meant to be used in StarterGui, I think you're talking about ScreenGui? killerbrenden 1537 — 4y
0
yeah its screen sorry. xXGAMEONGAMERSXx -3 — 4y
0
and put your localscript inside of the button and write script.Parent.MouseButton1Click:Connect(function() --// Rest of code killerbrenden 1537 — 4y
View all comments (3 more)
0
well it is in the button and ill fix that xXGAMEONGAMERSXx -3 — 4y
0
its not working xXGAMEONGAMERSXx -3 — 4y
0
You can’t reference any and all GUIs through StarterGui if you desire to provide functions that modify the players UI live. If this is what you want, you must reference PlayerGui instead. Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

LocalScript inside of the button and write this.

script.Parent.MouseButton1Click:Connect(function()
    if script.Parent.Parent.TextLabel.Visible == true then
        script.Parent.Parent.TextLabel.Visible = false
    elseif script.Parent.Parent.TextLabel.Visible == false then
        script.Parent.Parent.TextLabel.Visible = true
    end
end)

Any changes you make in the StarterGui will not have an affect on the player's screen.

Hope this helped! If this worked, don't forget to select this as an answer!

Hierarchy (Setup)

Ad

Answer this question