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

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

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

2 comments

0

Is this script on the server or client?

0

sorry, but i have fixed the issue

1 answer

✓ Accepted answer

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)

1 comment

0

thank you!

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