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
 

How do I use return in a RemoteFunction to get a value?

Previous Thread :: Next Thread 
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
18 Apr 2016 07:23 PM
Server:

local WeaponHolder = game.ServerStorage:WaitForChild("Weapons")
local Remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("InventoryLevelReturn")

Remote.OnServerInvoke = function(player, Item, ClientLevel)
for _,ItemWithLevel in pairs(WeaponHolder:GetChildren()) do
if ItemWithLevel.Name == Item then
local Level = ItemWithLevel:WaitForChild("Level")
ClientLevel = Level.Value
print(ClientLevel)
end
end
return player, Item, ClientLevel
end


Local:

local Title = script.Parent:WaitForChild("Title")
local Level = script.Parent:WaitForChild("Level")
local Remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("InventoryLevelReturn")


-- Starting Script --
local LevelNumber = 0

Remote:InvokeServer(Title.Text, LevelNumber)

Level.Text = LevelNumber


The Server always prints the correct number, but when I do "Level.Text = LebelNumber" it still prints 0. I'm using a RemoteFunction so I can wait for the value of LevelNumber to be changed (chill TimeTicks). So how would I be able to make this work or use return correctly.



Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Apr 2016 08:08 PM
-- server
RemoteFunction.OnServerInvoke = function(Player,x)
return x*2
end
--


-- client
local FiveTimesTwo = RemoteFunction:InvokeServer(5)
print(FiveTimesTwo) --> 10
--



Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
18 Apr 2016 08:20 PM
This isn't working Q-Q

-- Local:

local Title = script.Parent:WaitForChild("Title")
local Level = script.Parent:WaitForChild("Level")
local Remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("InventoryLevelReturn")
-- Starting Script --
local LevelNumber = 0

Remote:InvokeServer(Title.Text, LevelNumber)
print('LevelChanged')

Level.Text = "Lvl. " .. LevelNumber
print('Number Changed')


-- Server:
local Remote2 = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("InventoryLevelReturn")

Remote2.OnServerInvoke = function(player, Item, ClientLevel)
ClientLevel = 0
local newLevel = 0
for _,ItemWithLevel in pairs(WeaponHolder:GetChildren()) do
if ItemWithLevel.Name == Item then
local Level = ItemWithLevel:WaitForChild("Level")
newLevel = Level.Value
print(newLevel)
end
end
return player, Item, ClientLevel + newLevel
end

It's changing Level.Text to Lvl. 0



Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
18 Apr 2016 08:23 PM
Nevermind Fixed,

-- Server:

local Remote2 = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("InventoryLevelReturn")

Remote2.OnServerInvoke = function(player, Item, ClientLevel)
ClientLevel = 0
local newLevel = 0
for _,ItemWithLevel in pairs(WeaponHolder:GetChildren()) do
if ItemWithLevel.Name == Item then
local Level = ItemWithLevel:WaitForChild("Level")
newLevel = Level.Value
print(newLevel)
end
end
return ClientLevel + newLevel
end

-- Local:

local Title = script.Parent:WaitForChild("Title")
local Level = script.Parent:WaitForChild("Level")
local Remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("InventoryLevelReturn")
-- Starting Script --

LevelNumber = Remote:InvokeServer(Title.Text, LevelNumber)
print('LevelChanged')

Level.Text = "Lvl. " .. LevelNumber
print('Number Changed')



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