Trying run function on ClientSide through Event

Ok so. Im making effects and i need run them on client by server.
how i can do it.
im trying use remote event for it but getting error

--CODE
local function huh()
	print("huhuhuhuh")
end
wait(2)
game.ReplicatedStorage.RemoteEvent:FireAllClients(huh)
--ERROR
  22:36:49.569 - Workspace.ki2005rill.LocalScript:2: attempt to call a nil value
22:36:49.569 - Stack Begin
22:36:49.570 - Script 'Workspace.ki2005rill.LocalScript', Line 2
22:36:49.570 - Stack End
1 Like

The parameter doesn’t accept functions. You could only put a value in it.

but why, any way to do it in other method?

Btw in wiki it says Tuple, so it can send functions too. Like with ModuleScripts

you can do

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
print(“huh”)
end)

ik ik, but this is not that i want

You could put the function that you made under the client event, so it’d look like this:

game.ReplicatedStorage.RemoteEvent:FireAllClients()
local function huh()
	print("huhuhuhuh")
end
huh()

It’ll function the same, so it’s unnecessary to put it above it.

No, I think this person is trying to run code on the client not run it on the server, like sending code through a remoteevent, maybe like something incommand does?

Like this.
Ok listen up all.
I have effects on server, since server its bad place for effects i need run them on client, but i wont 2441141 lines of code, thats why im creating function on server.
btw effects

1 Like

This is not possible, and quite frankly is full of potential for hackers. If a hacker wanted to run a function of whatever they want, they could do lots of things since they now have access to run functions on the server. Again, this is not possible, and probably isn’t necessary.

1 Like

sigh. ok listen. im creating effect on server. (hackers cant edit script source. right?)
so hackers cant do anything.
EDIT: In other words

--SERVER
local function huh()
    print("huhuhuhuh")
end
wait(2)
game.ReplicatedStorage.RemoteEvent:FireAllClients(huh)
--LOCAL
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(func)
    func()
end)

No, it’s not possible to send functions by :FireAllClients, only values (such as plr, in which will transfer the player to the localscript that’s OnClientEvent).

Why go through all this hassle? Just create a function on the client

local function createEffect(type, colors, ...)
    --do the effects on the client
end

effectsRemoteEvent.OnClientEvent:Connect(createEffect)

as i said i wont have 1501209821089 lines of code to make a effect. Thats why im making them on server

I apologize, but I’m confused. What do you mean by:

Simply moving the code onto the clientside shouldn’t make the code any longer.

This isn’t possible, you can’t send a function through a RemoteEvent.

You could send the text of the function and then call loadstring() on the client, but you can’t because loadstring() was removed from the client. To get around this you would need to use something called LBI (Lua Bytecode Interpreter) to run the code instead.

Oh god. Why i cant run function from server to client. well ty for help.