Value check not working

I basically have a check to check if the players value is 3. If it is 3 it should kick them, but it’s not working. No errors are being produced either.

The code is in a script located in serverscriptservice

Code:

local value = game.Players.LocalPlayer.Stats.Warnings

value.Changed:Connect(function()
	if value.Value == 3 then
		game.Players.LocalPlayer:Kick("3 Warnings")
	end
end)
1 Like

You can’t use game.Players.LocalPlayer in a server script.

What do you suggest I use instead of localplayer?

In your normal leaderstats script, make it so that if the player’s value is three then you kick him or her.

1 Like

You could use a CharacterAdded inside a PlayerAdded

Something like this:

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect (function(plr)
-- Value check here
end
end)

(Please do correct me if I made any typos since I’m typing this on mobile)

1 Like