Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

RemoteEvents not yielding, little soldiers using humanoids?

Asked by 6 years ago

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.

0
Any Errors? If so Tell me. MrGaming4me 28 — 6y

1 answer

Log in to vote
0
Answered by
Kikitob 105
6 years ago

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
Ad

Answer this question