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

Gui wont popup when i touch a part?

I have a script in a part that is supposed to make it so when any player touches the part it will show the person who touched the part a Gui.

local Part = script.Parent

Part.Touched:connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
            local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
            Player.PlayerGui.finish gui.Frame.Visible = true
    end
end) 


2 comments

0

server scripts can't access guis from players unless it clones one and gives it to the player

0

line 7: Player.PlayerGui["finish gui"].Frame.Visible = true

2 answers

ch0kehold is nearly correct. If you have a space in the instance's .Name, you need to access it like this:

--////Assuming that you're trying to access a Frame that is inside an object named 'Finish GUI'

--//You don't need to assign script.Parent to a variable, as you only use it once
--local Part = script.Parent

--//script.Parent.Touched is the same as Part.Touched, but without the wasted variable
script.Parent.Touched:connect(function(HIT)
	local h = HIT.Parent:FindFirstChild("Humanoid")
	if h then
		local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
		--You put the object name inside square brackets, as a string
		Player.PlayerGui['Finish GUI'].Frame.Visible = true
	end

7 comments

0

it still won't work for some reason

0

Can you post a screenshot of your game's hierarchy, so we can see where all your instances are? @Prbol1201

0

ok

0

how do i post it

0

Use imgur or a similar service

0

Put the script inside of the Frame

// thats the line where i think your error is:

Player.PlayerGui.finish gu.Frame.Visible = true

// replace it with that:

 Player.PlayerGui.["finish gui"].Frame.Visible = true   

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