How can I do this?

So I am making an invisibility potion in Roblox. My goal is to make it so that you can somewhat see your character locally, but everyone else in the server (not including you) can’t see you at all.

So far it’s going well, locally, I’ve set the transparency to 0.7, but the server part is the problem, every time I’ve tried to make the server detect if it was dealing with the player or other players. it just seemed to never work.

With the current scripts I have now, it will work, but only if you double click it, and I just want it to not get confused but just work as intended.

These are my two current scripts, local and server.
Local:

local UIS = game:GetService("UserInputService")
script.Parent.Activated:Connect(function()
	UIS.InputBegan:Connect(function(input, gpe)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			local Player = script.Parent.Parent
			script.Parent.EnableEvent:FireServer()
			for _, child in ipairs(Player:GetChildren()) do
				if child:IsA("BasePart") then
					if child.Name == "HumanoidRootPart" then
						child.Transparency = 1
					else
						child.Transparency = 0.7
					end
				elseif child:IsA("Accessory") then
					child.Handle.Transparency = 0.7
				end
			end
			wait(20)
			for _, child in ipairs(Player:GetChildren()) do
				if child:IsA("BasePart") then
					if child.Name == "HumanoidRootPart" then
						child.Transparency = 1
					else
						child.Transparency = 0
					end
				elseif child:IsA("Accessory") then
					child.Handle.Transparency = 0
				end
			end
		end
	end)
end)

And server:

script.Parent.EnableEvent.OnServerEvent:Connect(function(player, Name)
	local Player = script.Parent.Parent
	if Name ~= script.Parent.Parent.Name then
		for _, child in ipairs(Player:GetChildren()) do
			if child:IsA("BasePart") then
				child.Transparency = 1
			elseif child:IsA("Accessory") then
				child.Handle.Transparency = 1
			end
		end
		wait(20)
		for _, child in ipairs(Player:GetChildren()) do
			if child:IsA("BasePart") then
				if child.Name == "HumanoidRootPart" then
					child.Transparency = 1
				else
					child.Transparency = 0
				end
			elseif child:IsA("Accessory") then
				child.Handle.Transparency = 0
			end
		end
	end
end)

And the end result looks like this:

Any help is apprechiated!

try using just a client remote event like this:

for i, v in pairs(game.Players:GetPlayers() do
       if v.Name ~= plrName then
       remoteEvent:FireClient(v)
end
end

so how would i apply this to my script? i know it won’t work in the local script, but why would i fire back something at the client?

For the server loop through the body parts and make them invisible
Then fire an event to the client and make yourself [On the client so only you see] partially invisible

Well I tried to somewhat implement what he suggested, do you know whats not working here?

function hi()
	local Player = script.Parent.Parent
	for _, child in ipairs(Player:GetChildren()) do
		if child:IsA("BasePart") then
			child.Transparency = 1
		elseif child:IsA("Accessory") then
			child.Handle.Transparency = 1
		end
	end
	wait(20)
	for _, child in ipairs(Player:GetChildren()) do
		if child:IsA("BasePart") then
			if child.Name == "HumanoidRootPart" then
				child.Transparency = 1
			else
				child.Transparency = 0
			end
		elseif child:IsA("Accessory") then
			child.Handle.Transparency = 0
		end
	end
end

script.Parent.EnableEvent.OnServerEvent:Connect(function(player, Name)
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Name ~= Name then
			hi()
		end
	end
end)

You could try this

Server:

local Character = script.Parent.Parent
local WaitTime = 20

function Invisible()
	
	for _, child in pairs(Character:GetChildren()) do

		if child:IsA("MeshPart") or child:IsA("BasePart") then

			child.Transparency = 1

		end

		if child:IsA("Accessory") then

			child.Handle.Transparency = 1

		end

	end
	
	game.ReplicatedStorage.ClientInvis:FireClient(0.7)

	wait(WaitTime)

	for _, child in pairs(Character:GetChildren()) do

		if child:IsA("MeshPart") or child:IsA("BasePart") and child.Name ~= "HumanoidRootPart" then

			child.Transparency = 0

		end

		if child:IsA("Accessory") then

			child.Handle.Transparency = 0

		end

	end
	
	game.ReplicatedStorage.ClientInvis:FireClient(0)
	
end

Potion.Activated:Connect(function()
	
	Invisible()
	
end)

end

Client:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

game.ReplicatedStorage.ClientInvis.OnClientEvent:Connect(function(Transparency)
	
	for _, child in pairs(Character:GetChildren()) do
		
		if child:IsA("MeshPart") or child:IsA("BasePart") and child.Name ~= "HumanoidRootPart" then

			child.Transparency = Transparency

		end
		
		if child:IsA("Accessory") then

			child.Handle.Transparency = Transparency

		end
		
	end
	
end)

it prints out “Unable to cast value to Object”

Hey so the description you gave sounds very similar to the super power training simulator invisibility power. I actually have a video on making this exact thing, I think it could be of use to you: