|
| 04 Oct 2015 05:16 PM |
things like
function1(function()--[[code]]end)
remoteevent:FireServer(function()--[[code]]end)
Instance.new("BodyVelocity",SenseiWarrior).velocity = CFrame.new(SenseiWarrior.Torso.Position,YourGirlsDMs.Position).lookVector * 10 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 04 Oct 2015 05:22 PM |
| You can definitely pass functions as arguments. You already do it all the time when you connect functions to events. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:26 PM |
In Sensei's example, I don't think you actually can.
It treats the function as a userdata value. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:28 PM |
Server:
local lol = Instance.new("RemoteEvent", workspace) lol.OnServerEvent:connect(function(func) func() end)
Client:
local rm = workspace:WaitForChild("RemoteEvent")
rm:FireServer(function() print'hi' end)
Error:
Workspace.Script:3: attempt to call local 'func' (a userdata value) |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:29 PM |
Crap.
It does work.
I forgot about the automatic player argument server side. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:35 PM |
| Doesn't work in live servers |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:41 PM |
Is there anyway I could do this through remote events then?
Instance.new("BodyVelocity",SenseiWarrior).velocity = CFrame.new(SenseiWarrior.Torso.Position,YourGirlsDMs.Position).lookVector * 10 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Oct 2015 05:45 PM |
| You can't send a function created on the client to the server or vice-versa. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:46 PM |
| I only tested in Play Solo. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2015 05:48 PM |
| module scripts can be required from both the client and the server. place a function in it and you have that function at both sides. but you might want to choose what function to send. In that case you just place all the function in a table in the module script and then instead of sending the function just send the key of the function you want to call. |
|
|
| Report Abuse |
|
|