#this code is causing a error for some reason

24 messages · Page 1 of 1 (latest)

keen granite
#

PlayerHum = nearestPlayer:WaitForChild("HumanoidRootPart") causes the error Infinite yield possible on 'Players.hackman93029:WaitForChild("HumanoidRootPart")' (hackman93029 being me) does anyone know how to fix this?

rich knot
#

@keen granite Hello could you please provide the context for this script so i can help

keen granite
#

sure thing

#

one sec

#

local part = script.Parent.HumanoidRootPart

local maxDistance = 10

wait(5)
while true do
    wait()
    local nearestPlayer, nearestDistance
    for _, player in pairs(Players:GetPlayers()) do
        local character = player.Character
        local distance = player:DistanceFromCharacter(part.Position)
        if not character or 
            distance > maxDistance or
            (nearestDistance and distance >= nearestDistance)
        then
            continue
        end
        nearestDistance = distance
        nearestPlayer = player
        PlayerHum = nearestPlayer:WaitForChild("HumanoidRootPart")
    end
    if nearestPlayer ~= nil then
        print(PlayerHum:GetAttribute(Vector3))
        CFrame.lookAt(PlayerHum:GetAttribute(Vector3)) 
        wait()
    end
end```
#

@rich knot here is the script

brittle brambleBOT
#

studio** You are now Level 3! **studio

rich knot
#

ok

#

let me see

keen granite
#

also care to explain lol

rich knot
#

ok dude

#

its not what it looks like

#

can you tell me what it is supposed to DO

#

that might help me find the problem

brittle brambleBOT
#

studio** You are now Level 1! **studio

rich knot
#

@keen granite

grave basalt
#

get a life before you attempt humor please

rich knot
#

@keen granite

grave basalt
#

@keen granite

#

@keen granite

#

@keen granite

keen granite
#

oh sorry lol

keen granite