I know how to use remote events but not remote functions. I made a Local Script that makes it so that when i press a button, i use :InvokeServer() and on the Server Script that's receiving the invoke, a part is created. I tried to return the part so that my Local Script has access to it but i can't seem to do it.
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFunction = ReplicatedStorage:WaitForChild("RemoteFunction")
local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char.Humanoid
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then
RemoteFunction:InvokeServer()
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFunction = ReplicatedStorage:WaitForChild("RemoteFunction")
function RemoteFunction.OnServerInvoke(player)
return local Box = Instance.new("Part",game.Workspace)
Box.Transparency = 0.5
Box.CanCollide = false
Box.Anchored = false
Box.Size = Vector3.new(19.29, 0.87, 2)
Box.Name = "Box"
end

3 comments
Code?
k hold on
Return has to be the very last thing in your code.