Basically I’m trying to make a remote function that invokes the clients mouse position and sends it to the a remote event to fire off a projectile. Honestly remote functions just continue to confuse me and I have no idea how to do this. sos
You can learn more about RemoteFunction instances here:
Can you provide the code you have thus far?
You don’t really want to invoke the client with remote functions, it’s usually better to use remote events.
– LOCAL SCRIPT –
local replStorage = game:GetService("ReplicatedStorage")
local clickEvent = replStorage:WaitForChild("ClickEvent")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local clickPos = input.Position
clickEvent:FireServer(clickPos)
end
end)
– SERVER SCRIPT –
local replStorage = game:GetService("ReplicatedStorage")
local clickEvent = replStorage:WaitForChild("ClickEvent")
clickEvent.OnServerEvent:Connect(function(player, clickPos)
--projectile code
end)
Current organisation in the explorer window. This solution makes use of a RemoteEvent.
RemoteFunctions are basically RemoteEvents, but you can return something. For example.
In a LocalScript:
local String = RemoteFunction:InvokeServer()
print(String)
In a ServerScript:
RemoteFunction.OnServerInvoke = function()
return "Whats up?"
end
And the output would be:
Whats up?
This can be good for Code systems, or even the character shop inside of Bloxy Kart. Hope this helps!