Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

RemoteEvents not yielding, little soldiers using humanoids?

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.

1 comment

0

Any Errors? If so Tell me.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.