How to make one-way invisibility power?

So I have an invisibility key-bind script that works 100% with no scripting problems at all. But what I want to achieve now is making it so you can see yourself but others cant see you. The problem is I don’t know where to start from so if anyone could help that would be much appreciated.

game.ReplicatedStorage.invisible.OnServerEvent:Connect(function(plr, var, susan)

	local TS = game:GetService("TweenService")
	local Info = TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	for _, v in pairs(susan.Parent:GetDescendants()) do
		if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" and v.Name ~= "LeftFoot" and v.Name ~= "RightFoot" and v.Name ~= "face" then
			if var == "Began" then
				TS:Create(v, Info, {Transparency=1}):Play()
			elseif var == "Ended" then
				TS:Create(v, Info, {Transparency=0}):Play()
			end
		end
	end
end)

What is susan here?

In order to make yourself invisible to everyone but your own self, you will will need to do a couple of changes.
At the moment, you fire the server telling that you want to turn a player invisible (I suppose Susan? :smiley: Although what you should do, is take the plr argument that correspons to the player that wants to be invisible. After that, get the character associated to it, and then turn that invisible.

Something like:

Apart from this. You will now need to have the server Fire ALL clients, BUT the one that requested it. The invisibility has to happen local side. So one more event connection, from server to everyone.

I can give a working example if you want me to :smiley: !

Do you want yourself to be fully visible or a little bit transparent (for yourself)?

So what you would want to do is make use of the client, what i would do is remove or make your character transparent on all clients except for yours.

I would start by instead of making the player invisible from the server send a request to the server that will then send a request to all the clients :FireAllClients with the player’s name that needs to be set transparent and run …

local TS = game:GetService("TweenService")
	local Info = TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	for _, v in pairs(susan.Parent:GetDescendants()) do
		if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" and v.Name ~= "LeftFoot" and v.Name ~= "RightFoot" and v.Name ~= "face" then
			if var == "Began" then
				TS:Create(v, Info, {Transparency=1}):Play()
			elseif var == "Ended" then
				TS:Create(v, Info, {Transparency=0}):Play()
			end
		end
	end

and add an if statement so that if the received player’s name is not your name then make them transparent

Sorry i know this sounds a bit confusing but if you need more help i can provide more

Susan is the name of the local script in conjunction with this (its the susan from fantastic four)

The script makes your character fully invisible to you and others but I want them to be able to see themselves while others cannot

Here is an example of what I mean

[When key bind is pressed]

--Local Script
game.ReplicatedStorage.InvisEvent:FireServer()

[when the server receives the request]

--Script
game.ReplicatedStorage.InvisEvent.OnServerEvent:Connect(function(Plr)
  game.ReplicatedStorage.InvisEvent:FireAllClients(Plr)
end)

[The clients receive the request]

--Local script
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

game.ReplicatedStorage.InvisEvent.OnClientEvent:Connect(function(Plr)
  if game.Players.LocalPlayer.Name ~= Plr.Name then
    --Make Invisible
    for _, v in pairs(Plr.Character:GetDescendants()) do
		if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" and v.Name ~= "LeftFoot" and v.Name ~= "RightFoot" and v.Name ~= "face" then
			if var == "Began" then
				TS:Create(v, Info, {Transparency=1}):Play()
			elseif var == "Ended" then
				TS:Create(v, Info, {Transparency=0}):Play()
			end
		end
	end
  end
end)

This should work but there might be some errors, wrote it in here instead of studio

Ok so I actually found a way and I apologize if I wasted anyone’s time I was just confused at the moment but with this script, i am invisible to others except myself

--[[ Varaibles ]]--
local uis=game:GetService("UserInputService");

--[[ Main ]]--

-- pressing
uis.InputBegan:connect(function(input)
	if input.KeyCode==Enum.KeyCode.E then
		game.ReplicatedStorage.invisible:FireServer("Began", script)
		wait(1)
		local TS = game:GetService("TweenService")
		local Info = TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
		for _, v in pairs(script.Parent:GetDescendants()) do
			if v:IsA("BasePart") and v.Name~= "HumanoidRootPart" then
				TS:Create(v, Info, {Transparency=0}):Play()
			end
		end
	end
end)

-- left 
uis.InputEnded:connect(function(input)
	if input.KeyCode==Enum.KeyCode.E then
		game.ReplicatedStorage.invisible:FireServer("Ended", script)
	end
end)```
2 Likes