|
| 28 Feb 2016 05:39 AM |
Let's say I press key Z, this fires a RemoteFunction and that RemoteFunction creates a Part, is it possible to return the position of that part back to the Localscript that fired the RemoteFunction and print it? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 28 Feb 2016 05:44 AM |
| Well, yeah? Just make the invoke on the server return Part.Position and then print the return from RemoteFunction:InvokeServer(...) |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 05:53 AM |
so return part.Position
and then in LocalScript print(part.Position) What is the returned defined as? |
|
|
| Report Abuse |
|
|
Egzekiel
|
  |
| Joined: 10 Jan 2011 |
| Total Posts: 1079 |
|
|
| 28 Feb 2016 06:08 AM |
script 1:
local part RemoteFunction:InvokeClient/Server()
script 2:
function RemoteFunction.OnServer/ClientInvoke(player) local newpart=Instance.new("Part",workspace) --Put some stuff return newpart end
|
|
|
| Report Abuse |
|
|
Egzekiel
|
  |
| Joined: 10 Jan 2011 |
| Total Posts: 1079 |
|
|
| 28 Feb 2016 06:09 AM |
Well, you can return newpart.Position as you're looking for it's possiton
|
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 06:22 AM |
| yeah but what would the returned be defined as in LocalScript? |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 06:30 AM |
When you fire the event to the server it makes a part
When you make the part have the server fire an event to the client with the position. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 11:52 AM |
uh but I mean if I did this
-- LocalScript local plr = game.Players.LocalPlayer mouse = plr:GetMouse() enable = false
mouse.KeyDown:connect(function(key) if key == "C" then local theEvent = game.ReplicatedStorage:WaitForChild("PrintMe") if not enable then enable = true theEvent:FireServer() print (returned) wait(4) enable = false end end end)
-- Script
local theEvent = game.ReplicatedStorage:WaitForChild("PrintMe")
theEvent.OnServerEvent:connect(function(plr)
print("You've said Hello.") wait(1) return "Say Goodbye"
end
where I've typed 'print(returned)' what would I put instead of "returned" |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 11:55 AM |
| Event.OnClientEvent:wait() |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 28 Feb 2016 01:06 PM |
| It should. In about an hour when I can be on a computer I'll make you an example |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 01:08 PM |
Thankyou, that'd be great. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 03:12 PM |
Server script local event = Instance.new("RemoteEvent", game.ReplicatedStorage) event.Name = "example"
event.onServerEvent:connect(function(player) local basePart = Instance.new("Part", game.Workspace) event:fireClient(player, basePart) end)
Client game.ReplicatedStorage.example.onClientEvent:connect(function(basePart) print(basePart.Position) end)
game.ReplicatedStorage.example:fireServer()
This is just an example you will have to connect it up with your script. |
|
|
| Report Abuse |
|
|
DevDays
|
  |
| Joined: 16 Dec 2015 |
| Total Posts: 112 |
|
|
| 28 Feb 2016 03:15 PM |
LocalScript:
local part, finish = RemoteFunction:InvokeServer("w0t") repeat wait() until finish print(part.Position)
ServerScript: function RemoveFunction.OnServerInvoke:connect(function(Player, type) if type == "w0t" then local p = Instance.new("Part", game.Workspace) return p, true end end
|
|
|
| Report Abuse |
|
|