Is there a way to run client code on server scripts?

Is it possible with things like coroutines and/or loadstring?

You can use a remote event to talk to a server script and send the function (with the block of code in) you want it to run.
If you mean pieces of code only accessible in local scripts, no

So you can use things like FireServer to get it to run lines of code from the client?

Yes you can. That’s exactly what remote events are for.

I’m sorry, i don’t think i explained myself well. I meant something like
and same with the server.

no, what you need to do is send what you want to destroy into the server side script and then when the server recieves, destroy it

like this

(this is client script)

RemoteEvent:FireServer(item) -- you can send variables through remotes


RemoteEvent.OnServerEvent(plr, item) -- create a new variable with the variable you passed
     -- now you can do anything with that item, such as

but since it’s from the client and sent through the server, you need to add a player variable first

1 Like

Oh, right. I thought you could send a piece of code in the brackets straight to the server/client to run, as if it was like spawn or a coroutine.

without needing a script on the other side listening for it.

oh okay, glad I could help.


I think i’ll mark your post as the solution, thank you.

1 Like