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

Open GUI when clicking part?

This is what I have:

function onClicked(playerWhoClicked)
	local player = game.Players:GetPlayerFromCharacter(playerWhoClicked.Parent);
	player.PlayerGUI.Elevator.Frame.Visible = true;
end
 
script.Parent.ClickDetector.MouseClick:connect(onClicked)

I just want the GUI to be visible when you click the part.

1 answer

You don't need to get the player from character. MouseButton1Click returns the actual player object on click.

function onClicked(playerWhoClicked)
    playerWhoClicked.PlayerGui.Elevator.Frame.Visible = true; -- Spelling error on PlayerGui
end

script.Parent.ClickDetector.MouseClick:Connect(onClicked)

Any questions? Leave them in the comments. Thanks!

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