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

Open GUI when clicking part?

Asked by 7 years ago

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

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

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!

Ad

Answer this question