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

how to make it so when you click on a part it will show you a gui?

Asked by 6 years ago

here is my script

game.Players.PlayerAdded:Connect(function(plr)
    script.Parent.MouseClick:Connect(function()
    plr.PlayerGui.Colorgui.Frame.Visible = true
end)
end)

there is an error in the output and it is this 11:21:17.225 - Colorgui is not a valid member of PlayerGui 11:21:17.225 - Stack Begin 11:21:17.225 - Script 'Workspace.Part.ClickDetector.Script', Line 4 11:21:17.226 - Stack End Now before you say that well it's because you don't have an colorgui in the playergui i do but it isn't doing what i would like it to

help please.

0
Use a remote event. User#25115 0 — 6y

1 answer

Log in to vote
1
Answered by
EgoMoose 802 Moderation Voter
6 years ago
Edited 6 years ago

So there are a few issues that arise from the way you are approaching this.

  1. You cannot access individual player's GUI directly from the server.

A player's GUI does not replicate with the server (and rightly so). There's no point in that information being sent to the server as unlike work geometry, physics, etc. Literally only the individual player is going to see their GUI.

The solution to this would be to either use a remote event (which i'd argue is overly complicated) or to use a local script.

local colorFrame = game.Players.LocalPlayer.PlayerGui:WaitForChild("Colorgui"):WaitForChild("Frame")

game.Workspace.ExampleButton.ClickDetector.MouseClick:Connect(function(player)
    colorFrame.Visible = true
end)
  1. Even if 1. wasn't a problem you are connecting an event to the click detector each time a player joins the game.

This is problematic as anytime anyone clicks the part then everyone's GUI will be affected.

If this is your intention then you should connect 1 event on the server and use a remote event and the FireAllClients method to replicate the change to every player.

0
Do i put that in a localscript underneath workspace or somewhere else? XxGamerSporkXx_YT 1 — 6y
0
nvm i figured it out thanks XxGamerSporkXx_YT 1 — 6y
Ad

Answer this question