How would I go about making different character transparencies for other players?

So, I have a cloak script that whenever you press V, you turn invisible for the entire server. This cloak is only available to a certain team/rank.

How would I go about making it so that when you press V, you turn half transparent to yourself and people that are on that certain team/have that certain rank, but still appear fully invisible to everyone else who is not on that team/rank?

I have attempted this, but I don’t know how to approach it;
heres the two scripts that I’m using for the cloak system.

Local:

local Player = game.Players.LocalPlayer

local RemoteEvent = game:GetService("ReplicatedStorage").CloakRemote

local doors = game.Workspace["ARC-478"].Interaction.KeybindSystems




local C = true
local Equipped = false
local Invisible = false
local UserInputService = game:GetService("UserInputService")


function invis1()
	for i,v in pairs(doors:GetDescendants()) do
		if  v:IsA("MeshPart") or v:IsA("BasePart") or v:IsA("UnionOperation") then
			if v.Name == "Base" then
				v.Transparency = .5
				v.CanCollide = false
			end
		end
		
	end
	end


function invis4()
	for i,v in pairs(doors:GetDescendants()) do
		if  v:IsA("MeshPart") or v:IsA("BasePart") or v:IsA("UnionOperation") then 
			if v.Name == "Base" then
				v.Transparency = 0
				v.CanCollide = true
			end

		end
	end
end

			


Player.CharacterAdded:Connect(function(Char)
	local hum = Char:WaitForChild("Humanoid")

	UserInputService.InputBegan:Connect(function(Input, gameProcessedEvent)
		Equipped = true
		if gameProcessedEvent == false and Input.KeyCode == Enum.KeyCode.V then
			if Char then
				if Player:GetRankInGroup(11425159) >=253 or game.Players.LocalPlayer.Team.TeamColor == game.Teams["Intelligence Agency"].TeamColor or game.Players.LocalPlayer.Team.TeamColor == game.Teams["Internal Security Department"].TeamColor then
					if C and Equipped then
						C = false
						if Char.LowerTorso.Transparency == 0 then


							hum.WalkSpeed = 50
							RemoteEvent:FireServer(1,Char)
							invis1()

							wait(1)
							Invisible = true

						else

							hum.WalkSpeed = 16
							RemoteEvent:FireServer(2,Char)

							invis4()
							wait(1)
							Invisible = false
						end
						C = true

					end
				
				end
			end


		end
	end)

end

Server:

local RemoteEvent = game:GetService("ReplicatedStorage").CloakRemote
local Teams = game:GetService("Teams")
local remote2 = game:GetService("ReplicatedStorage").Redacted
RemoteEvent.OnServerEvent:Connect(function(Player,N,Character)
	if Player:GetRoleInGroup(11425159) == "The Vice Administrator" or "The Administrator" or Player.TeamColor == Teams["Intelligence Agency"].TeamColor or Player.TeamColor == Teams["Internal Security Department"].TeamColor then
		local rank = Character.Head.Rank
	local Smoke = RemoteEvent:WaitForChild("Smoke")
	local Elec = RemoteEvent:WaitForChild("Elect")
	local Clone = Smoke:Clone()
	local Clone2 = Elec:Clone()
	Clone.Parent = Character:WaitForChild("HumanoidRootPart")
	Clone2.Parent = Character:WaitForChild("HumanoidRootPart")
		if N == 1 then
		
			wait(0)
			rank.Frame.Visible = false
			for i,v in pairs(Player.Character:GetDescendants()) do
				if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal") then
					if v.Name ~= "Humanoid" then
						if v.Name ~= "HumanoidRootPart" then
							v.Transparency = 1

						end
					end
				end
			end
		wait(.5)
		Clone:Destroy()
		Clone2:Destroy()
		elseif N == 2 then
	
			wait(0)
			rank.Frame.Visible = true
			for i,v in pairs(Player.Character:GetDescendants()) do
				if v:IsA("BasePart")  or v:IsA("MeshPart") or v:IsA("Decal") then
					if v.Name ~= "Humanoid" then
						if v.Name ~= "HumanoidRootPart" then
							v.Transparency = 0

						end
					end
				end
			end
		wait(.5)
		Clone:Destroy()
		Clone2:Destroy()
	end
	end
	end)

Use 2 RemoteEvents (Server to client)

  • half transparent
  • transparent

When client press V, send event to server.
Server sends ‘half transparent’ RemoteEvent for certain team, And send ‘transparent’ RemoteEvent for not in certain team.

1 Like

Alright. So I would do something like this?

remote.OnServerEvent:Connect(function()
     if player:GetRoleInGroup(blah) == "blah" or player.Team == "blah" then
      halftransparentremote:FireAllClients()
    else
         transparentremote:FireAllClients()
    end
end
end)
1 Like

Welp, I turn half invisible for everyone. I don’t know why?

local remote3 = game.ReplicatedStorage.Invis
local teams = game.Teams
remote3.OnClientEvent:Connect(function(team, rank, cloaker)
	for i,player in pairs(game.Players:GetPlayers()) do
		if player.Team.TeamColor == teams["Intelligence Agency"].TeamColor or teams["Internal Security Department"].TeamColor or player:GetRankInGroup(11425159) >=253 then

	
		for i,v in pairs(cloaker:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal") then
					if v.Name ~= "Humanoid" or v.Name ~= "HumanoidRootPart" then
				v.Transparency = .5
				end
				end
		end
		elseif player.Team.TeamColor ~= teams["Intelligence Agency"].TeamColor or player.Team.TeamColor ~= teams["Internal Security Department"].TeamColor or not player:GetRankInGroup(11425159) >=253 then 
		for i,v in pairs(cloaker:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal") then
					if v.Name ~= "Humanoid" or v.Name ~= "HumanoidRootPart" then
					v.Transparency = 1
				end
				
			end
		end
		end
	end
	
end)

Also, I am unsure how to fire a remoteevent only to a team.

This line is wrong, Code should be this:
if player.Team == teams["Intelligence Agency"] or player.Team == teams["Internal Security Department"] or player:GetRankInGroup(11425159) >=253 then

  1. If statement have teams["Internal Security Department"].TeamColor, always true.
  2. Use Team instead of TeamColor

I still appear half transparent :frowning:

(forgot to say “to everyone”,)