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

You can’t just fix this script- there’s many things you need to add.

For starters, to save the banned players add them to the table

How do you do that, Can you maybe do it for me and send the script so i learn from it.

This will be my last reply to this forum- and when I’m replying to you, I’m trying to put this in the nicest way possible.

The reason for the DevForum is to assist you in a script when there is a minor bug that you aren’t able to debug and need an extra set of eyes on- not to fully teach you an entire concept or write out an entire script for you.

When you aren’t able to understand what we’re saying an give us useless information, we’re not able to assist you any further and you’re pretty much on your own.

I gave you the creator documentation so that you can maybe understand something about tables and grow and learn, but you trying to avoid this is not helping any one out at all. When you replied to me and said I’m not helping you- I am, you just can’t see it. I’m trying to guide you but you’re just not understanding that and I’m sorry.

Please also don’t be a jerk to anyone trying to help you dude. All of us are and we can’t send you videos or screenshots of a script that isn’t working and needs a lot of maintenance.

Sorry and good luck

Yes, I do understand your point and I do see your point but I clearly stated that I wanted help and if you are unable to help me then don’t reply to the chat or anything else reason, why I did this forum, is so that people who care or willing to help me out properly can help me out and I do find it very inappropriate to say “don’t be a jerk” as it can be a little bit immature but anyways if you can’t help me then that’s fine and I had help from people who actually send videos and screenshots (since you were saying “we” as if everybody does that) but have a nice day! Thank you for your help :slight_smile:

Riddle is indeed trying to help you here. On the devforums, help you should expect to receive is people leading you onto the right path, not telling you exactly what you should do (so like, giving you a link to the documentation of the datastore service/telling you to search for the datastore service, NOT giving you an exact script on what you are supposed to do.)

Anyways, the reason your script does not work is mainly due to the player’s ban not actually being saved. When the player rejoins the game, as long as they are not in the same server, the table “bannedPlayers” changes, as the player was never banned in the other server.

Now, What you would want to do is to save this table named “bannedPlayers” onto the datastore. The datastore is an extremely “simple” thing, which you can find many good and useful tutorials on from no matter youtube or even its documentation site. To simplify what it does, its basically like a “global” storage for variables, which allows you to store and take information from it no matter which server you are in.

Your problem here is that your script is missing an entire, important chunk of code, and on the devforums, the rules literally forbid asking for others to help you write entire scripts. In this case, we can only point you towards the right direction. Sure, I can include some images if you want, but there wouldn’t exactly be a point, as it could only be an image of the final result (otherwise I would ltierally be breaking the rules)

If you have any specific problems you come across from youtube tutorials or the documentation of the datastore, you can ask us, and we can even help you write parts of your script, however, you have to atleast have a script for us to help you on (not your current script, that works perfectly fine, what you need a complete seperate thing, you could put it in the same file, but it is still completely seperate and performs a completely different function)

How do you save the table, I’m a beginner.

Try reading the link riddle gave first, it has some nice explanations and examples. If theres anything very specific in it that you dont understand, ask me again

if you need more examples, I can give you a snippet of code as well

oh wait

uhhhh nvm thats the wrong link that one is for tables

this one

srry they all look the same in link form lol

I don’t understand it. I confused and I have ADHD so it’s hard for me to learn.

Bro I annoyed I don’t understand this at all.

I tried to use some sources from before and I redo the code why isn’t this working

game.Players.PlayerDied:Connect(function(player)

player:Kick(“You have been banned for 25 minutes.”)

wait(1500)

player:Unban()

end)

It’s not working because these methods don’t exist in the API. I’m assuming you used something like ChatGPT to create this code.

I redo some of it but yes I did use ChatGPT but I had to edit it because bot was using wrong stuff and wasn’t giving me what wanted so I stop using it.

now first you want to access the datastore, that part should be extremely simple as there is an example for it which you can techinically just copy over (its in the documentation)

now, in the function which finds out if the player died or not (search on google for player died fucntion), you want to do Datastore:SetAsync(user the player’s userId here for the key, when the player was banned)

after that, in the playeradded function, you want to user Datastore:GetAsync(player’s user id here) to obtain when they were banned, do some math to figure out how long they are still banned for, and if the answer is > 0, you want to kick them using player:kick(), if not, you dont really need to remove it from the datastore (since each time they rejoin, the calculation would figure out they are already unbanned anyways)

remember that you can do simple google searches like “how to detect when a player dies” to get functions you need most of the time

Okay, I got these things I hope you know I have 10% of knowledge about scripting so I can’t really write my own code and put things to together

If you think you aren’t skilled enough to put thing together yet, I would suggest following a youtube tutorial, and changing it based on what you need with your own knowlegde (since its easier to change a script then completely write one)

srry late reply