I want to make only environment invisible not players
Your post is a bit confusing, but I’ll try to answer it based off how I interpreted it.
I assume you are looping through everything in an area, then want to only process the object in the area if it is not a player.
There are a few ways to achieve this. Here are a couple:
local Players = game.Players
for _, Object in ipairs( -- [[ Put the thing you are looping here]] --) do
if Players:GetPlayerFromCharacter(Object.Parent) then
continue
end
-- add the code to make it invisible here
end
local Players = game.Players
for _, Object in ipairs( -- [[ Put the thing you are looping here]] --) do
if not Players:GetPlayerFromCharacter(Object.Parent) then
-- add the code to make it invisible here
end
end
Note that these may become laggy due to the large number of calls to the GetPlayerFromCharacter function. An alternative is to store the player’s before hand.
i.e.
local Chars = {}
for _, Player in ipairs(game.Players:GetPlayers()) do
table.insert(Chars, Player.Character)
end
for _, Object in ipairs( -- [[ Put the thing you are looping here]] --) do
if table.find(Chars, Object.Parent) then
continue
end
-- add the code to make it invisible here
end
for i,v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("Part") or v:IsA("Texture") or v:IsA("Decal") or v:IsA("SpawnLocation") then
task.spawn(function()
originTransparency[v] = v.Transparency
game.TweenService:Create(v,TweenInfo.new(0.5),{Transparency = 1}):Play()
end)
end
end
it’s make everything invisible but I don’t want players to be invisible
Yeah, that’s what I determined was the case. In my original post, I provided a solution to it.
Player’s Texture, Decal, Accessories are still invisible
try this alternative:
local Chars = {}
for _, Player in ipairs(game.Players:GetPlayers()) do
table.insert(Chars, Player.Character)
end
for _, Object in ipairs( -- [[ Put the thing you are looping here]] --) do
IsOfChar = false
for _, Char in ipairs(Chars) do
if Object:IsDescendantOf(Char) then
IsOfChar = true
end
end
if IsOfChar then continue end
-- add the code to make it invisible here
end
Tbh, you may be better making EVERYTHING invisible, player and all, then just seperately making the players visible again
Never knew :IsDescendantOf() exist, Thanks
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.