The application of this button would be for hiding other players on your screen in a parkour game. Other players could potentially be playing the same level as you and therefore be in your screen view. You should be able to toggle whether other players are visible on your screen or not.
I have a screen GUI with a frame inside and a textButton inside the frame. The local script is located inside of the textButton.
local hideButton = script.Parent.Parent.HidePlayers local Players = game:GetService("Players") local plr = game.Players.LocalPlayer repeat wait() until plr.Character local chr = plr.Character local hum = chr:WaitForChild("Humanoid") function hideOrShowOthers() if hideButton.Text == "Hide Players" then hideButton.Text = "Show Players" for i, v in pairs(game.Workspace:GetDescendants()) do if v:IsA("Humanoid") then if plr.Name ~= v.Name then v.Humanoid.LocalTransparencyModifier = 1 else v.Humanoid.LocalTransparencyModifier = 0 end end end end if hideButton.Text == "Show Players" then hideButton.Text = "Hide Players" for i, v in pairs(game.Workspace:GetDescendants()) do if v:IsA("Humanoid") then if plr.Name ~= v.Name then v.Humanoid.LocalTransparencyModifier = 0 else v.Humanoid.LocalTransparencyModifier = 0 end end end end end hideButton.MouseButton1Click:Connect(hideOrShowOthers)
My biggest issue so far is understanding what to loop through and how to loop through all the currently connected players and get their humanoids, so that I can use LocalTransparencyModifier to change their transparency. If my Idea is wrong, I would appreciate corrections on why I wouldn't be able to do so.
Also, if my code is not good enough to understand the concept, I would appreciate hints on how I could go about completing it. I am not looking for someone to do all the work for me but instead would like to use this question as a way to help me learn how my concept is wrong and how I can improve on the concept I have given in order to eventually complete it.
So, how I would be able to manipulate the transparency of every player connected to the game on a button click, so that they are invisible to you and only you until you click the button again? Keep in mind that your player must always be visible and the character visibility changes should only happen on your own screen so that other players can use the button for the same purpose (of making other players not visible on your screen).
I am quite new to Roblox Studio, so I would appreciate any explanations about why my thought process might be wrong and how to improve my problem-solving skills in Roblox.
you can just set every player to a transparency of 1, also making every singe part in them transparent, then would still be bale to be collided with but you can do that easily, theres articles on how to make players non collidable with eachother. anyways, its simple, find every player, then locate to their chaarcters, then set all of the parts in all the chaarcters to transparency = 1, use a pairs loop like this:
for _,i in pairs(game.Players:GetChildren()) do--this gets every single player in the game wait() for _,ii in pairs(i.Character:GetDescendants()) do--get every part in the player without multiple loops if ii.ClassName == "Part" or ii.ClassName == "Decal" then if not ii.Name == "HumanoidRootPart" then ii.Transparency = 1 end end end end
(Fixed the script)
Edit: and when making them visible again, ignore the humanoidroot part like this, also i spaced it out a bit i like doing that when scripting):
for _,i in pairs(game.Players:GetChildren()) do--this gets every single player in the game wait() for _,ii in pairs(i.Character:GetDescendants()) do--get every part in the player without multiple loops if ii.ClassName == "Part" or ii.ClassName == "Decal" then if not ii.Name == "HumanoidRootPart" then ii.Transparency = 0 end end end end
that should work. It loops through every player, and for every player, it loops through all the parts in it's character, and to avoid scripts and stuff like that, it checks to see if the child being tested is a part, then makes it transparent / invisible.
hope this helps :3 <3