For some reason, if the test and playerP are == to each other it will run. In testing both the test and playerP will equal the player's name.
local PLAYERS = game:GetService("Players") local playerP = PLAYERS.LocalPlayer game.ReplicatedStorage.RemoveNPC.OnClientEvent:Connect(function(test) print("Fired") print(test) print(playerP) if playerP ~= test then print("B") local way = game.Workspace:WaitForChild("wayFind") way:Destroy() print("E") end end)
So I think the problem with the code is the fact that you are getting 2 different player Instances. The if statement compares the instance PlayerP to the instance Test, but one is on the client and one is on the server. In order to fix this issue, I would compare the names of the player(s) like so:
if playerP.Name ~= test.Name then
Okay, I found out why what happened. My playerP value needs a .Name because of the test value being sent to the player is Boss.Name.
local PLAYERS = game:GetService("Players") local playerP = PLAYERS.LocalPlayer game.ReplicatedStorage.RemoveNPC.OnClientEvent:Connect(function(test) print("Fired") print(test) print(playerP.Name) if playerP.Name ~= test then --THIS LINE HERE print("B") local way = game.Workspace:WaitForChild("wayFind") way:Destroy() print("E") end end)