Here are my two pieces of code:
--Server local selected = false local rf = game:GetService("ReplicatedStorage").Remotes local RequestMovePoint = rf.RequestMovePoint local function getReadBack() end script.Parent.ClickDetector.MouseClick:Connect(function() if selected == false then script.Parent.Humanoid.WalkToPoint = RequestMovePoint:InvokeClient(game.Players:WaitForChild(script.Parent.BelongsTo.Value)) print(2) selected = not selected else selected = not selected end end)
and
rf = game:GetService("ReplicatedStorage").Remotes rmp = rf.RequestMovePoint local player = game.Players.LocalPlayer local mouse = player:GetMouse() function createNewPoint() mouse.Button2Up:connect(function() newPoint = mouse.hit.p print(1) end) return newPoint end rmp.OnClientInvoke = createNewPoint
My goal is for when you click the unit, and **THEN ** click somewhere else, then the unit moves to the location you clicked.
RemoteFunctions are not yielding like they are supposed to, I am using humanoids to move the little soldiers.
This should fix it. The reason why yours didn't work is because its instantly returning it and not waiting for the event.
rf = game:GetService("ReplicatedStorage").Remotes rmp = rf.RequestMovePoint local player = game.Players.LocalPlayer local mouse = player:GetMouse() function createNewPoint() mouse.Button2Up:Wait() return mouse.hit.p end rmp.OnClientInvoke = createNewPoint