How do I disable a particular object that is in all characters (locally)?

Let’s imagine the following:

1.All characters have an RPName in their head
2. I have a button that will disable this RPName from the users’ heads

However I don’t know how I do to disable the RPName(BillboardGui.Enabled) on all users and for users entering the server. How do I do that?

Note1: I know how to make the button click script (local script).
Note2: I think the code related to RPName deactivation will be in a ServerScript(remote event: Client–>Server) but I’m not sure.

sorry if this is confusing.

1 Like

This can, and should, be done entirely on the client since this is a feature the client would be toggling.

Store the button’s state as a variable. When the button is toggled you set everyone’s visiblity to the button state, then any new entering players.

some “pseudo” code if you will.

local Players = game:GetService("Players")

local State = true --// true by default ..?

local function OnButtonActivation() --// some function you would connect to an event for a button click
    State = not state
    for i, Player in pairs(Players:GetPlayers()) do
        local Character = Player.Character

        if Character and Player:HasAppearanceLoaded() then
            local Head = Character:FindFirstChild("Head")
            local Tag = Head:FindFirstChild("Tag")

            Tag.Enabled = State
        end
    end
end

-- now everytime a player joins, the first time their character spawns
-- we will update their tag property. 
Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Wait() --// despawn tag once
    Player.Character.AncestryChanged:Wait() --// wait until we are 'loaded' but not really
    
    local Head = Player.Character:WaitForChild("Head")
    local Tag = Head:WaitForChild("Tag")

    Tag.Enabled = State
end)
1 Like