Hello, I would like to make a system that will move players, but I want them to stop if another player is on the node/part in front of them, I have the system to move them but I don’t know how to check if another player is on the node/part in front.
What have I attempted?
I attempted to use a bool that is enabled when the player enters and disables on leaving the node/part, but this infinitely stops the player if enabled.
Current Script ~
function onTouched(hit)
local np = script.Parent.NextPart.Value
local npp = script.Parent.NextPart.Value.Position
local hum = hit.Parent:FindFirstChild("Humanoid")
hum:MoveTo(npp)
end
script.Parent.Touched:connect(onTouched)
Bool Attempt
function onTouched(hit)
local currentTouchNow = script.Parent.TouchingNow.Value
currentTouchNow = true
local np = script.Parent.NextPart.Value
local npp = script.Parent.NextPart.Value.Position
local TouchNow = np.NextPart.Value
if TouchNow == true then
local hum = hit.Parent:FindFirstChild("Humanoid")
hum:MoveTo(npp)
currentTouchNow = false
end
end
script.Parent.Touched:connect(onTouched)