I have this gui button that when clicked makes player dissapear but i just realised it only works on client side, how do i make player invisible on server side?
Btw this is my current code that works perfectly on client side:
local button = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local activated = false
local function dissapear()
if activated == true then
local descendants = character:GetDescendants()
activated = false
for i, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.Transparency = 0
character.Head.face.Transparency = 0
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.DisplayWhenDamaged
end
end
else
local descendants = character:GetDescendants()
activated = true
for i, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.Transparency = 1
character.Head.face.Transparency = 1
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOn
end
end
end
end
local function onButtonActivated()
if activated == false then
dissapear()
character.HumanoidRootPart.Transparency = 1
activated = true
button.BackgroundColor3 = Color3.new(0.133333, 1, 0)
else
dissapear()
character.HumanoidRootPart.Transparency = 1
activated = false
button.BackgroundColor3 = Color3.new(0.6, 0.6, 0.6)
end
end
button.Activated:Connect(onButtonActivated)

3 comments
Thanks
Wait but when i click the button everyone on the server gets invisible is there a way to check who clicked it?
the first keyword in the server script called 'player' tracks the localplayer