Why isn't this script not working on Roblox Studio?

Hello, I try to make whenever you die in-game you get banned for 25 minutes and for some odd reason the script that I trying to run is not working. Can you tell me how to fix it? Or maybe I’m putting it in the wrong place or using the wrong type of script or it’s the script itself.

Script:

local bannedPlayers = {}

game.Players.PlayerDied:Connect(function(player)
local playerId = player.UserId
local time = os.time()
bannedPlayers[playerId] = time + 1500
player:Kick(“You have been banned for 25 minutes.”)
end)

game.Players.PlayerAdded:Connect(function(player)
local playerId = player.UserId
local banTime = bannedPlayers[playerId]
if banTime and banTime > os.time() then
player:Kick(“You are still banned for “…math.ceil((banTime - os.time()) / 60)…” minutes.”)
end
end)

Help me fix the script please.

Please only chat here if you helping with this problem! Thank you.

Are you even saving the bannedPlayers table?

When concatenating strings, you use two dots rather than three.

player:Kick(“You are still banned for ".. math.ceil((banTime - os.time()) / 60)..” minutes.”)

What’s that? What do you mean by that.

That isnt the fully scope of why it isnt working, he’s not even saving the banned players table so it has no data to compare it to when the player joins the game

I don’t think this is a method of the Players service.

The data doesn’t need to save really.

If a player is banned; it’s banned for x amount of time.

Saving the table isn;t necessary

You have to save the banned player table using some sort of data saving method and then load it when the player joins so you can see if they have data in it or not

It is necessary if the server shuts down if all players leave or are kicked.

Nvm I understand what you mean now

How do you do that? I’m new. I’m basically beginner scripter

Datastore Service is how you save data

He’s literally just kicking the player, it’ll only work if they join back in the same server

1 Like

Yep I understand now, I haven’t really worked with banning or kicking players much

1 Like

Uhh, Can you help me solve the problem because I need help.

For starters, save the player you’re banning into the table.

The game is kill others players then get banned

I’m not sure how to assist you further?

It’s a script that whenever a player dies they get banned so can you help me to fix the script