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
RemoteEvent:FireClient(game.Players.LocalPlayer:Destroy())
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
(serverside)
RemoteEvent.OnServerEvent(plr, item) -- create a new variable with the variable you passed
-- now you can do anything with that item, such as
item:Destroy()
end)
but since it’s from the client and sent through the server, you need to add a player variable first
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.
asd
I think i’ll mark your post as the solution, thank you.
Just put a function as an argument when firing it to the client and tell the client to execute that piece of code. like
thing:FireClient(playerToExecute, function() stuff end
And on client you can do
thing.OnClientEvent:Connect(function(func: (any) -> nil) func() end
I’m probably too late to tell you.
How did you find this… Its been 3 years💀
My question is how did you find mine after 1 minute
Maybe cz it bumps the entire post to the top of this category?
Oh I’m new to deforum yeah I forgot