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

Why is the run text not appearing?

Asked by 1 year ago

What i am trying to do here is that if the zombie spots your torso then u get a text saying to run

the script is a localscript the script is inside the model of the zombie

local larm = script.Parent:FindFirstChild("HumanoidRootPart")
local rarm = script.Parent:FindFirstChild("HumanoidRootPart")


function findNearestTorso(pos)
    local list = game.Workspace:children()
    local torso = nil
    local dist = 10000
    local temp = nil
    local human = nil
    local temp2 = nil
    for x = 1, #list do
        temp2 = list[x]
        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
            temp = temp2:findFirstChild("HumanoidRootPart")
            human = temp2:findFirstChild("Humanoid")
            if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
                if (temp.Position - pos).magnitude < dist then
                    torso = temp
                    dist = (temp.Position - pos).magnitude
                end
            end
        end
    end
    return torso
end




while true do
    wait(1)
    local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
    if target ~= nil then

        local spotted = target.Parent.Name

        for i,child in pairs(game.Players:GetChildren()) do
            if child.Name == spotted then
                game.Players:WaitForChild(child.Name).PlayerGui.RUN.Label.Visible=true

            end
        end

        end
    end


1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Ad

Answer this question