How to make a GUI only appear for a certain player after clicking on an object

Hi everyone

I am creating a tech demo for one of my upcoming games and one of the things I need is a system for a billboard GUI to show up for the player that clicked the object.

I know how to get the GUI to show up, but the GUI shows up to all players on the server.
I tried using a LocalScript instead of a normal script, but that just broke the script and the GUI would no longer show up.

My layout:
image

My current code that shows the GUI, to all players: (activateKabob)
image

Thanks everyone

Have you tried a RemoteEvent ?
RemoteEvents: RemoteEvent | Roblox Creator Documentation
This makes thing that the player does on server go to client(only that player can see).

Script_ (Trainmaster2341 Editing) - Roblox Studio 4_19_2023 8_39_44 PM (3)

I would recommend putting the Event in ReplicatedStorage and make a client script in StarterPlayerScripts.

This in Server script.

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	-- player leaderstats
	game.ReplicatedStorage.RemoteEvent:FireClient(player,script.Parent.BillboardGui)
end)

This in the Client Script.

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(gui) -- local script already knows local player
	-- show gui
	gui.Enabled = true
	task.wait(5)
	gui.Enabled = false
end)

I hope this helps. ¯_(ツ)_/¯

Do I need to change the “gui” in that to something else? There is no errors but the GUI does not show up

Why not just use a localscript that handles MouseClick for cosmetic purposes while logic for server?

I thinks thats what Trainmaster2341 was suggesting, except linking the cosmetic and logistic with a remote event… correct me if I’m wrong

that is correct.

@Trainmaster2341 Enables the gui, however you need the Frame to become visible. Just change the localscript code to this:

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(gui) -- local script already knows local player
	-- show gui
gui:WaitForChild("Frame").Visible = true
task.wait(5)
gui:WaitForChild("Frame").Visible = false
end)

Alternatively you could just have the Frame visible and enable/disable the gui like @Trainmaster2341 recommended in his example

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.