Hello!
So I am creating a game and in the game there are booths that users can claim. I want it so that when one person claims the booth, their name shows up on the name text label and everyone be able to see it.
I first made a local script and put it in the surface gui, but it was only showing locally… so then I made a script and put it in serverScriptService which didnt work, then I put it in a regular script in the surface gui and that also did not work. Here is the script for a better look. How do I do this?
--local text = script.Parent
--local player = game.Players.LocalPlayer
local hold = workspace.Folder.Base.claim
local unclaim = workspace.Folder.Base.unclaim
unclaim.Enabled = false
hold.Triggered:Connect(function(player)
local text = script.Parent
local player = game.Players.LocalPlayer
text.Text = player.DisplayName
hold.Enabled = false
wait(1)
unclaim.Enabled = true
end)
unclaim.Triggered:Connect(function(player)
local text = script.Parent
text.Text = "name"
unclaim.Enabled = false
wait(1)
hold.Enabled = true
end)
Just create a bool value and an object value inside the booth, the bool value to check if its claimed/unclaimed, and the object value should be the object of the player who claimed it, then you can simply detect if the bool value changed and set the text to something like
local player = objectvalue.Value
text = player.Name .. "'s Booth"
then do the same for when a player leaves or unclaims it, simply set the value to false and the text to “Unclaimed Booth”
(do this through a localscript because the values are on the server)
you can also use a stringvalue instead of an objectvalue, so that you don’t need to use .Name
So basically, you have a booth model in the workspace, and the surfaceGui in the starterGui, you have to put the localscript inside the surfaceGui, and the value/s inside the booth model so that it isn’t client sided