generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Return in RemoteFunction

Previous Thread :: Next Thread 
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
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 is not online. 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
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
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 is not online. 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 is not online. 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
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
28 Feb 2016 06:22 AM
yeah but what would the returned be defined as in LocalScript?
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
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
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
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
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
28 Feb 2016 11:55 AM
Event.OnClientEvent:wait()
Report Abuse
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
28 Feb 2016 11:57 AM
_._
Report Abuse
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
28 Feb 2016 12:03 PM
That does not work
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
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
HatLicense is not online. HatLicense
Joined: 16 Mar 2015
Total Posts: 330
28 Feb 2016 01:08 PM

Thankyou, that'd be great.
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image