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

Why doesn't my frame's visibility propertry set to true?

Asked by
seikkatsu 110
5 years ago

Soooo, i want a gui,whose visible property is set to false, to be set to true after my charcter touched a part. The part is in the workspace, the text label is parented to a frame which is parented in a screen gui, and the script i work in is a normal one

local part = script.Parent
part.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then
        local frame = game.StarterGui.ScreenGui.Frame
        if frame.Visible == false then
        frame.Visible = true
        end
    end
end)

Thanks for the help in advance

0
Is this script on the server or client? ForeverBrown 356 — 5y
0
sorry, but i have fixed the issue seikkatsu 110 — 5y

1 answer

Log in to vote
1
Answered by
yoyyo75 74
5 years ago
Edited 5 years ago

Hi! so the issue would be comming from line 5

local frame = game.StarterGui.ScreenGui.Frame

because that would not affect the GUI of your player, notice when you get in a game under Players you have PlayerGui so thats what you want to set the visibility

So firstly you have to get the Gui of the Player, not the Gui in StarterGui

local part = script.Parent
part.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then
        -- hit.Parent is the character so the line below gets player's folder from the character
        local p = game.Players.getPlayerFromCharacter(hit.Parent)

        -- so replace your frame variable with the player's ScreenGui
        local frame = p.ScreenGui.Frame

        if frame.Visible == false then
        frame.Visible = true
        end
    end
end)
0
thank you! seikkatsu 110 — 5y
Ad

Answer this question