Im unsure on how I would make i print what is what just so I can get the basics.
local Script in GUI
script.Parent.MouseButton1Click:Connect(function() local Crack = game.ReplicatedStorage.Money.Add.Code:InvokeServer() if Crack == "1" then print("Crack is 1") elseif Crack == "2" then print("Crack is 2") elseif Crack == "3" then print("Crack is 3") elseif Crack == "4" then print("Crack is 4") elseif Crack == "5" then print("Crack is 5") elseif Crack == "6" then print("Crack is 6") end end)
ServerScript In ServerScriptService
game.ReplicatedStorage.Money.Add.Code.OnServerInvoke(ReturnValue) function ReturnValue() local Value = math.random(1,6) print(Value) return Value end
Nothing Prints or returns. I already read the wiki but still don't understand how to do it. How can I make this work so I can further understand it?
So Remote Functions work differently from Event's, you cant put a function in the OnServerInvoke() scrictly because it, itself is already a function, and in this case, in your code "ReturnValue" is a passed variable.
instead you would want:
local remoteFunction = game.ReplicatedStorage.Money.Add.Code function remoteFunction.OnServerInvoke() local Value = math.random(1,6) print(Value) return Value end