Command does not work when playing with another player

  1. What do you want to achieve? Keep it simple and clear!
    I want to be able to become invisible with a command.

  2. What is the issue? Include screenshots / videos if possible!
    Everytime I join a game with my friend the command just DOES NOT work for me nor him. I’ve checked multiple times and it should’ve worked but it is not.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried looking for solutions but I couldn’t find a post that had an answer.

--[[SERVICES]]--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--[[VARIABLES]]--
local Events = ReplicatedStorage.CMDS

Events.InvisibilityEvent.OnServerEvent:Connect(function(Player, Username)
	local plr = Players:FindFirstChild(Username)
	if plr.Character.Head.Transparency == 1 then
		for _,v in plr.Character:GetDescendants() do
			if v:IsA("BasePart") then
				if v.Name ~= "HumanoidRootPart" then
					v.Transparency = 0
				end
			end
			if v:IsA("Decal") then
				v.Transparency = 0
			end
		end
	else
		for _,v in plr.Character:GetDescendants() do
			if v:IsA("BasePart") then
				if v.Name ~= "HumanoidRootPart" then
					v.Transparency = 1
				end
			end
			if v:IsA("Decal") then
				v.Transparency = 1
			end
		end
	end
end)

Please help. :slight_smile:

The script works perfectly fine for me. Are you sure you’re using a server script?

It works for me as well, try checking the console for any errors when you are in-game with your friend and make sure that script is a ServerScript, not LocalScript

The script seems to be working fine.
It is probably a server script so maybe the issue is the way you call the remote event.
If there is another local script that calls the event, can you share it so we can be able to help you?

This is a server script.

Post must be atleast 30char long🤓

I can show you the part where it sends the event.

if Command == "invisibility" or Command == "invisible" or Command == "invis" or Command == "inv" and PermLevel >= 1 then
	local Username = Split[2]
	if Username == "me" then Username = Player.Name end
	
	Events.InvisibilityEvent:FireServer(Username)
end

Yes this is a server script, as I said.

The code above is from a server script. The one firing the event is a local script. The code seems to be working PERFECTLY fine when playing alone. (That means if the player leaves the code starts working again) But the second anyone else other than you joins then it stops working. Not even an error, nothing!