You can write your topic however you want, but you need to answer these questions:
-
I want to make all characters invisible with a certain tag except mine Keep it simple and clear!
-
MY player becomes invisible as well
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local VisibleEvent = ReplicatedStorage.Events.Visible
local LocalPlayer = Players.LocalPlayer
local hidden = false
local originalTransparency = {}
RunService.RenderStepped:Connect(function()
for _, player in CollectionService:GetTagged("Playing") do
if player == LocalPlayer then
continue
end
local character = player.Character
if character ~= LocalPlayer.Character then
for _, object in ipairs(character:GetDescendants()) do
if object:IsA("BasePart") or object:IsA("Decal") then
if hidden then
if originalTransparency[object] == nil then
originalTransparency[object] = object.Transparency
end
object.Transparency = 1
else
if originalTransparency[object] ~= nil then
object.Transparency = originalTransparency[object]
originalTransparency[object] = nil
end
end
elseif object:IsA("BillboardGui") then
if hidden then
object.Enabled = false
else
object.Enabled = true
end
end
end
end
end
-- cleanup destroyed instances
for object in pairs(originalTransparency) do
if not object or not object.Parent then
originalTransparency[object] = nil
end
end
end)
VisibleEvent.OnClientEvent:Connect(function(state)
hidden = (state == "Invisible")
end)
I just want to know why my own local character is becoming invisible too, i only want other player’s characters to be invisible.
