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:
My current code that shows the GUI, to all players: (activateKabob)
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).
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)
@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