I noticed a lot of obbies and other parkour games have a really poor implementation of “Hide Players” such as people respawning and it not hiding them, so heres a simple resource button for it, if theres bugs let me know in the replies (The file is a Frame that you put into a screengui)
HideOthers.rbxm (9.7 KB)
This is also a bad implementation. If you’re going to hide characters, they shouldn’t be in the workspace at all. Setting the transparency of all the character’s objects is not a reliable way of hiding it. It’s prone to so many failures, no matter how many types of instances you account for.
this is the only image of the script in the thread and that i have so i’m just gonna reply to it
pairs() could be replaced for generalized iteration here
the part:IsA("MeshPart") check is redundant because MeshParts are BaseParts
there’s no reason to not include elseif part:IsA("Decal") into the BasePart check because they have the exact same code
the code is just generally not very good
okay thanks for the tip ![]()
chars
Everybody is gonna use this image lul.
Anyway, the code can be condensed into one singular function, something like changeTransparency and include the transparency value as a parameter.
Like others have mentioned, theres a redundant MeshPart check. And checking if the “part” is a decal, could be a replacement instead, not making a separate line, but in the same statement.
This is a personal point in my scripting style, but theres no type definition for functions and parameters and no checking if the specified character even is the character at all.
And its just not a good way of hiding the character, like others have mentioned, though it is the most straight forward, making them transparent aka hiding them.
A better way might be parenting them to another service like ReplicatedStorage, something like this:
-- client
function HidePlayers(visible : boolean) : ()
for _, player in game.Players:GetChildren() do
if not player or player == game.Players.LocalPlayer then continue end
if player.Character.Parent == game.ReplicatedStorage and visible then
player.Character.Parent = workspace
else
player.Character.Parent = game.ReplicatedStorage
end
end
end
Im not sure if this is the most efficient way, because I haven’t needed or done anything similar, except like body viewing from 1st person and camera manipulation.
But it is sure better than 2 functions and redundant code.
Here’s how I do it in my game.
This uses Fusion. “Characters” is a folder in the workspace. The “hidden” state depends on other logic, but it’s set to true when the character should be hidden. Pretty simple!
More
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local hideEnabled = false
local connections = {}
local function hideCharacter(character)
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") or part:IsA("MeshPart") then
part.Transparency = 1
elseif part:IsA("Decal") then
part.Transparency = 1
end
end
end
local function showCharacter(character)
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") or part:IsA("MeshPart") then
part.Transparency = 0
elseif part:IsA("Decal") then
part.Transparency = 0
end
end
end
local function onPlayerJoined(plr)
if plr == LocalPlayer then return end
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("HumanoidRootPart")
if hideEnabled then
hideCharacter(char)
end
end)
if plr.Character and hideEnabled then
hideCharacter(plr.Character)
end
end
local function enableHiding()
for _, p in ipairs(Players:GetPlayers()) do
onPlayerJoined(p)
end
table.insert(connections, Players.PlayerAdded:Connect(onPlayerJoined))
end
local function disableHiding()
for _, p in ipairs(Players:GetPlayers()) do
if p ~= LocalPlayer and p.Character then
showCharacter(p.Character)
end
end
for _, conn in ipairs(connections) do
conn:Disconnect()
end
connections = {}
end
local function buttonClicked()
hideEnabled = not hideEnabled
if hideEnabled then
enableHiding()
else
disableHiding()
end
end
script.Parent.Activated:Connect(buttonClicked)
Never really used fusion, forgive me, but seems quite basic, setting the character to nil I also find to be a good idea.
Yup. Keep in mind, if the client uses a character’s position to determine if it should be hidden, it may break. In my game, a user gets hidden when they are above a height limit. Setting their parent to nil would stop the replication of their position, making them hidden indefinitely. When I discovered this, I moved the logic to the server, while the client manages hiding the characters.
fusion really isn’t a fast lib; i’d recommend keeping it for UI and UI alone because it’s use cases outside of that aren’t really worth the sacrifices you get for using it. it’s the knit dilemma over again, using something that was made for a specific use-case outside of that use-case with misunderstood ideals and fundamentals that ends up harming games
consider a config, attribute or globals module that has a signal for event change?


