Checking client value

recently I made a script that checks a value in the client and sees if that value isn’t equal to the server value and then kicks them but I’m getting an error from it

-- Servies
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

-- RemoteEvent
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")


local function PlayerAdded(Player)

	local ServerPlayerData = ReplicatedStorage:WaitForChild("ChangeValue")
	Player.CharacterAdded:Connect(function()
		RemoteEvent.OnServerEvent:Connect(function(Data,CilentPlayer)
			if Data.Value ==  ServerPlayerData.Value then
				print("Work")
			else
				Player:Kick("IntValue Was Changed")
			end
		end)
	end)    
end

Players.PlayerAdded:Connect(PlayerAdded)

Value is not a valid member of Player “Players.static2240”

I use a command bar to fire it.
game.ReplicatedStorage.CellShadeCilentToData:FireServer(game.ReplicatedStorage.ChangeValue, game.Players.static2240)

RemoteEvent.OnServerEvent sends the player first, not the arguments (flip it around)

1 Like

I try it and still it gave me the same error

don’t send a player argument at all, just the arguments, roblox sends the player argument automatically

In case I worded this confusingly (which I do all the time) look at the example from the developer hub

1 Like

As @HugeCoolboy2007 said it needs to be like this and It should work all fine.

  -- Local Script    

    local RepStorage = game:GetService("ReplicatedStorage")
    RepStorage.CellShadeCilentToData:FireServer(RepStorage.ChangeValue)

    -- Server Script

    RemoteEvent.OnServerEvent:Connect(function(CilentPlayer,Data)
1 Like

Found the problem. I printed the data and somehow it returned it as a player.

Yes that’s why he said, swap the arguments