Fixing permission-based system

Hello, I want to know how to fix this, i started using FireClient on remote events since i only used FireServer, i want to know the correct way on how to use them, here is a script i made but i keep getting an error, here is the script

Script
–[[
RANK: 1, Player
RANK: 2, VIP
RANK: 3, Mod
RANK: 4, Admin
RANK: 5, Creator
–]]

local ControlRanks = {
	Rank3 = {1454922591};
	Rank4 = {};
	Rank5 = {};
}

-- Remotes
local ClientRanks = game.ReplicatedStorage.ClientRanks

game.Players.PlayerAdded:Connect(function(player)
	for i,v in pairs(ControlRanks.Rank3) do
		if player.UserId == v then
			--// Moderator Permissions
			player.Chatted:Connect(function(msg)
				if msg:sub(1,6) == ".rank " then
					local Target = game.Players:FindFirstChild(msg:sub(7))
					if not Target then
						warn("Invalid Target")
					end
					if Target then
						ClientRanks:FireClient(player,Target)
					end
				end
			end)
		end
	end
end)

LocalScript

local ClientRanks = game.ReplicatedStorage.ClientRanks

ClientRanks.OnClientEvent:Connect(function(Plr,Target) 
	print(Target.Name)

end)

Can you include the error message you got in your post?
Also the next time you make a topic you should title it something that relates to what your issue is.

When you bind a function to OnClientEvent you don’t need to include the player it was sent to, it could just be:

ClientRanks.OnClientEvent:Connect(function(Target)
...

Target'

In the localscript you don’t need to reference Plr. (its a local script. the player knows who they are)

Try changing that one line to:
ClientRanks.OnClientEvent:Connect(function(Target)

Still Says the same thing…

Assuming you did as @Blokav said, and took our the player parameter from the callback function on the client, you shouldn’t be having that error.

Can you send us the code you have currently?

If you changed the connect event and do not have the player referenced anywhere else it will error. Try adding this to the top of the script local Plr = game:GetService("Players").LocalPlayer

1 Like