My goal is to make a temporary 1 day ban when the player gets kicked out of the game 100 times, but the problem is I don’t know how to make the temporary ban
I’ve tried solutions on the developer hub, but the ban wasn’t placed. Here is the link to the solution I used:
if game.Players.plr.leaderstats.Kicks < 99 then
-- this is where the temporary ban should be placed
end
You are passing a instance to the FindFirstChild, that receives a string, try replacing it with game.Players:FindFirstChild(Player.Name). and comparing Player.leaderstats.Kicks which is an instance with 100, add a .Value after Kicks and before the ==.
It also looks like you are passing the wrong thing to AwardBadge in the last line, try it with Player instead of plr.
Or just try with this piece of code:
if game.Players:FindFirstChild(Player.Name).leaderstats.Kicks.Value == 100 then
game.Players:BanAsync({
UserIds = {Player.UserId},
Duration = 3600 * 24, -- 1 day
DisplayReason = "Just take a break.",
PrivateReason = "",
})
game:GetService("BadgeService"):AwardBadge(Player.UserId, --[[insert badge id]])
end
game.Players.PlayerAdded:Connect(function(plr)
local Player = plr.Name
-- the rest of my code is here, but i didn't add it
if game.Players:FindFirstChild(Player).leaderstats.Kicks == 100 then
game.Players:BanAsync({
UserIds = {Player.UserId},
Duration = 3600 * 24, -- 1 day
DisplayReason = "Just take a break.",
PrivateReason = "set this",
})
game:GetService("BadgeService"):AwardBadge(plr.UserId, 1276017689712360)
else
plr.Name.UserId doesn’t really make sense does it…
instead of Player.UserId do plr.UserId
Also like @TheMegaPeguinPro said before a intvalue/numbervalue (leaderstats.Kicks) will never be 100, don’t forget to add .Value after it
“Argument 1 missing or nil - Server - Script:23”
Script:23 is if game.Players:FindFirstChild(Player.Name).leaderstats.Kicks.Value == 100 then
the badge script also works when i did it without the statement around it.
I tested these changes, and it thinks that the Kicks value is still not 100, when it clearly shows 100 kicks in the leaderboard.
Note: I’m about to go eat dinner, and I won’t be here for around an hour.