How to run a local script without the player?

So basically, I’m doing an playerless script, but It has to delete the player in the server, and how can a local script run without being in local player.

Any scripts will help!

local scripts can’t run without a player, they are designed to be client sided scripts.

But can local scripts run in a player’s client? Even when the player is deleted

You mean when character is deleted? Scripts in startergui should still be running since they are not in the character.

No, I mean the player, in players service.

Oh nvm I misread your question.

It can’t, a local script can only run in the character, and the player. It can’t run anywhere else and since the player is destroyed so does the character. Meaning there is no ancestor where the script can be ran.

An alternative would be to delete the player on all the other clients

local function DeletePlayer(player)
  for _, v in pair(game.Players:GetPlayers() do
    if v ~= player then
      DeletePlayerRemote:Fire(v, player)
    end
  end
end

You forgot about ReplicatedFirst :smiley:
That is a service that is meant for localscripts too yk I know this is a old post but at least you know now

I also wanna mention to anyone else looking at this post for help you can set the RunContext of a server script to be “Client” which will basically run this script once per client no matter what its under

For info, if a Player instance gets destroyed, the player will automatically be kicked with the “Removed from data model” kick message.

1 Like

they actually can if you make a normal script and set its runcontext to client it will run everywhere where it gets replicated to the client

1 Like

Remember that isn’t a localscript that’s just a script with the RunContext changed they specifically asked for a “LocalScript” also not to mention this post is very old but yeah ur point is not invalid though this is also another way but that was not a thing back in that time of this post…

The point wasn’t to help the original poster (as it has been 4 years i assumed they figured it out or moved on), The post title may be brought up if someone is trying to put a client script outside of one of those instances. which was what i was trying to help with when posting that.

I am just letting u know but that idea u stated just runs for everyone it wouldnt run for a single client but yeah not everyone wants a client script to suddenly run it’s not the perfect solution but it’s one way but again depends on what u make

The difference with ur idea and a localscript is a script with a runcontext set to client just runs on every single client that can see the script while a localscript ONLY and will ONLY run for THAT CLIENT.

It’slocal not global for a reason bubba

Have you even tried it and compared the two?
A script is global and a localscript is truely local
(Its not global like a serverscript but it behaves like a global one and it’ll run for everyone no matter where it’s parented which is just the same as a regular server script only difference is it doesnt show on the server but it has the same behaviour like it)

I am not saying it isn’t local but this isnt the best way to make something local like what if you have an exclusive clientsided script you needed to run for JUST THAT PLAYER ur not just gonna parent it to somewhere where every client can see it are you?

Scripts with runcontext set to client with the CLASSNAME OF SCRIPT runs for every single client that can see the script replicated while a localscript?
Only runs if it’s authorised too.

Instead what you should do is parent a script like that to the playergui FIRST then using the client script itself u can THEN reparent it to where u like but dont just make one from the server there because it’ll not run in your favour.

1 Like

Roblox Studio requires an internet connection, therefore not local, local script would then only mean player, not server

That’s only for logging in and even opening place files stored on their servers
Everything else doesnt require an internet. If you are just aiming to use Roblox studio alone

However local files are an exception (yet it still asks you to login just to view a local file lol)

However this has nothing to do with local scripts and regular scripts

1 Like

When testing in roblox studio, your device is both the client and the server, you only need a connection for some of the roblox services

1 Like

this prolly cause RunContext didn’t even exist when this post was made.

For the original post I don’t understand why you would want to delete the player and still have local scripts run, since when the player instance is deleted you lose all connectivity with the server and get kicked from the game shortly after. But then again this post was made 4 years ago so why am I even here

1 Like