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

Infinite yield possible on 'Workspace.Felipe:WaitForChild("humanoid")'?

Asked by 4 years ago

I'll explain my situation. so this is a Round script or intermission script you'll notice that when looking at my script below,so when you join a game and the first round start, its fine,but on the second round this is where everything will break.

for i = GameTime, 0, -1 do
        if game.Workspace.Felipe:WaitForChild("humanoid").Health == 0  then
            print("STOP")
            break
        elseif game.Workspace.Felipe:WaitForChild("humanoid").Health ~= 0  then
            print("COUNT")
            ChangeText('GameTime ' ..i)
            wait(1)
        end
    end

this is where the error is found,the error only shows when on the second round. is there something im missing? cause im confused af. please help!

--math.randomseed(os.time())


--// Tables
Winners = {}

--// Modules
Settings = require(script.Settings)

--// Game Variables
Intermission = Settings.Intermission
GameTime = Settings.GameTime

--// Functions

function NightTIME()
    game.Lighting.FogEnd = 200
    local Sky = game.ReplicatedStorage.Sky:Clone()
    Sky.Parent = game.Lighting
end

function DayTIME()
    game.Lighting.FogEnd = 1000000000
    local Sky = game.ReplicatedStorage.DaySky:Clone()
    Sky.Parent = game.Lighting
end


function GameWait(Time)
    if Time > 0 then
        wait(Time)
    else
        return
    end
end



function back()
    if game.Workspace.Felipe.humanoid.Health == 0 then
        return
    end
end


function ChangeText(Text)
    local Players = game.Players:GetPlayers()
    for i = 1, #Players do
        Players[i].PlayerGui:WaitForChild("Main").Time.Text = Text
    end
end



--// Game
while true do
    local GameSettings = math.random(1,2)

    for i = Intermission, 0, -1 do
        ChangeText('Intermission ' ..i)
        wait(1)
    end

    local Players = game.Players:GetPlayers()
    for i = 1, #Players do
        Players[i].PlayerGui.SpectateGui.Enabled = false

        Players[i].Playing.Value = true
    end


    ChangeText('Game starting...')

    if GameSettings == 1 then
        DayTIME()
    elseif GameSettings == 2 then
        NightTIME()
    end

    wait(2)


    local Players = game.Players:GetPlayers()
    game.Workspace.GameProg.Value = true
    for i = 1, #Players do
        if Players[i].Playing.Value == true and Players[i].isAFK.Value == false then

            Players[i].Character.Torso.CFrame = game.Workspace.TP.CFrame


            Players[i].Character.Humanoid.WalkSpeed = 0
        end
    end

    for i = 5, 0, -1 do
        ChangeText('Starting in  ' ..i)
        wait(1)
    end 

    local Players = game.Players:GetPlayers()

    for i = 1, #Players do
        if Players[i].Playing.Value == true then
            if Players[i].CurrentGun.Value == "Glock" then
                local Weapon = game.ReplicatedStorage.Glock
                Weapon:Clone().Parent = Players[i].Backpack 
            elseif Players[i].CurrentGun.Value == "AWM" then
                local Awm = game.ReplicatedStorage.Awm
                Awm:Clone().Parent = Players[i].Backpack    

            elseif Players[i].CurrentGun.Value == "M4A1" then
                print("GiveM4a1")
            end
        Players[i].Character.Humanoid.WalkSpeed = 16
        end

    end



    ChangeText('BEGIN!')

    --or game.Workspace.Felipe:WaitForChild("humanoid").Health ~= 0
    for i = GameTime, 0, -1 do
        if game.Workspace.Felipe:WaitForChild("humanoid").Health == 0  then
            print("STOP")
            break
        elseif game.Workspace.Felipe:WaitForChild("humanoid").Health ~= 0  then
            print("COUNT")
            ChangeText('GameTime ' ..i)
            wait(1)
        end
    end

    -- Awarding players
    local Players = game.Players:GetPlayers()
    for i = 1, #Players do
        if Players[i].Playing.Value == true then
            table.insert(Winners, Players[i].Name)
            Players[i].leaderstats.Money.Value = Players[i].leaderstats.Money.Value + 10
            Players[i].leaderstats.Wins.Value = Players[i].leaderstats.Wins.Value + 0.5
            Players[i].Character.Humanoid.Health = 0
            Players[i].Playing.Value = false
        end
    end

    if GameSettings == 1 then
        game.Lighting:FindFirstChild("DaySky"):Destroy()
    elseif GameSettings == 2 then
        game.Lighting:FindFirstChild("Sky"):Destroy()
        game.Lighting.FogEnd = 1000000000
    end

    for i,v in pairs(game.Workspace.MinionsFOLD:GetChildren()) do
        v:Destroy()
    end

    game.Workspace.GameProg.Value = false
    ChangeText('GAME OVER!')
    wait(4) 

end

--//why am i doing this crap





0
there's a respawn script on the npc Cyrellejheff 11 — 4y
0
try capitalizing the h in humanoid Infocus 144 — 4y
0
the npc's Humanoid name is humanoid so no point of that i guess? Cyrellejheff 11 — 4y
0
After the First Round, check to make sure that the players are still in game.Workspace.Felipe? That might be why? b2lego 30 — 4y
0
It's "Humanoid". For the future, when it does "Infinite yield possible on...", that may mean that the instance cannot be found. User#29913 36 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You spelled humanoid wrong and yes it matters. Its WaitForChild:("Humanoid") Also is Felipe has a a respawn script in him it wont work because he's destroyed. You need a script in severscriptservice and a duplicate of felipe in serverstorage. Also you need a bool value in sever storage make sure its a bool value. At the end of a game make sure in the script you turn the bool value on. Heres the code. PS: make sure you place the duplicate of felipe in workspace a move him were you want and then put him in serverstorage

local Value = game.ServerStorage.Value
local MOB = game.ServerStorage.Felipe
if Value.Value == true then
    local M = MOB:Clone()
    M.Parent = workspace
end

0
you need felipes humanoid spelled Humanoid Nervousmrmonkey2 118 — 4y
0
is there a rule or something that you need a specific name for a Humanoid? Cyrellejheff 11 — 4y
0
i beleive so Nervousmrmonkey2 118 — 4y
Ad

Answer this question