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

Infinite yield possible?? what am i doing wrong?

Asked by 4 years ago
Edited 4 years ago

So i made a morph script where you click a button on a GUI to weld the parts to your character and its not working it's popping up this error:

Infinite yield possible on 'Workspace.HannahToots:WaitForChild("UsingMorph")'

Also the error is on line 13.

"Stack Begin Script 'ServerScriptService.MainScript', Line 13 Stack End"

-- [[ SERVICES ]] --
RS = game:GetService('ReplicatedStorage')
SS = game:GetService('ServerStorage')

-- [[ SIDE VARIABLES ]] --
Remote = RS:WaitForChild('MorphRemote')
Morph = SS:WaitForChild('Morphy')
-- [[ MAIN SCRIPT ]] --

function MorphHandler(Player) -- player is automatically a given variable
    local Character = Player.Character or Player.CharacterAdded:Wait()

    if Character:WaitForChild('UsingMorph').Value == true then
        Character.UsingMorph.Value = false
        for _,limb in pairs(Character:GetChildren()) do
            if limb:IsA('BasePart') then
                limb.Transparency = 0
            end -- check children class
        end -- loop
        -- delete morph
        if Character:FindFirstChild('Chest') then Character.Chest:Destroy() end
        if Character:FindFirstChild('Arm1') then Character.Arm1:Destroy() end
        if Character:FindFirstChild('Arm2') then Character.Arm2:Destroy() end
        if Character:FindFirstChild('Leg1') then Character.Leg1:Destroy() end
        if Character:FindFirstChild('Leg2') then Character.Leg2:Destroy() end
    elseif Character:WaitForChild('UsingMorph').Value == false then
        Character.UsingMorph.Value = true
        for _,limb in pairs(Character:GetChildren()) do
            if limb:IsA('BasePart') then
                limb.Transparency = 1
            end -- check children class
        end -- loop

        local modelname = Morph:Clone()

    if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Morphy") == nil then
        local g = modelname.Chest:Clone()
        g.Parent = Player.Character
        Plr.Character.UsingMorph.Value = true
        local C = g:GetChildren()
        for i=1, #C do
            if C[i].className == "Costume" or "Union" then
                local W = Instance.new("Weld")
                W.Part0 = g.Middle
                W.Part1 = C[i]
                local CJ = CFrame.new(g.Middle.Position)
                local C0 = g.Middle.CFrame:inverse()*CJ
                local C1 = C[i].CFrame:inverse()*CJ
                W.C0 = C0
                W.C1 = C1
                W.Parent = g.Middle
            end
                local Y = Instance.new("Weld")
                Y.Part0 = Player.Character.Torso
                Y.Part1 = g.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
        end

        local h = g:GetChildren()
        for i = 1, # h do
            h[i].Anchored = false
            h[i].CanCollide = false

        if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Leg1") == nil then
        local g = modelname.Leg1:Clone()
        g.Parent = Player.Character
        local C = g:GetChildren()
        for i=1, #C do
            if C[i].className == "Costume" then
                local W = Instance.new("Weld")
                W.Part0 = g.Middle
                W.Part1 = C[i]
                local CJ = CFrame.new(g.Middle.Position)
                local C0 = g.Middle.CFrame:inverse()*CJ
                local C1 = C[i].CFrame:inverse()*CJ
                W.C0 = C0
                W.C1 = C1
                W.Parent = g.Middle
            end
                local Y = Instance.new("Weld")
                Y.Part0 = Player.Character["Left Leg"]
                Y.Part1 = g.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
        end

        local h = g:GetChildren()
        for i = 1, # h do
            h[i].Anchored = false
            h[i].CanCollide = false
            if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Leg2") == nil then
        local g = modelname.Leg2:Clone()
        g.Parent = Player.Character
        local C = g:GetChildren()
        for i=1, #C do
            if C[i].className == "Costume" then
                local W = Instance.new("Weld")
                W.Part0 = g.Middle
                W.Part1 = C[i]
                local CJ = CFrame.new(g.Middle.Position)
                local C0 = g.Middle.CFrame:inverse()*CJ
                local C1 = C[i].CFrame:inverse()*CJ
                W.C0 = C0
                W.C1 = C1
                W.Parent = g.Middle
            end
                local Y = Instance.new("Weld")
                Y.Part0 = Player.Character["Right Leg"]
                Y.Part1 = g.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
        end

        local h = g:GetChildren()
        for i = 1, # h do
            h[i].Anchored = false
            h[i].CanCollide = false

if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Arm1") == nil then
        local g = modelname.Arm1:Clone()
        g.Parent = Player.Character
        local C = g:GetChildren()
        for i=1, #C do
            if C[i].className == "Costume" then
                local W = Instance.new("Weld")
                W.Part0 = g.Middle
                W.Part1 = C[i]
                local CJ = CFrame.new(g.Middle.Position)
                local C0 = g.Middle.CFrame:inverse()*CJ
                local C1 = C[i].CFrame:inverse()*CJ
                W.C0 = C0
                W.C1 = C1
                W.Parent = g.Middle
            end
                local Y = Instance.new("Weld")
                Y.Part0 = Player.Character["Left Arm"]
                Y.Part1 = g.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
        end

        local h = g:GetChildren()
        for i = 1, # h do
            h[i].Anchored = false
            h[i].CanCollide = false


    if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Arm2") == nil then
        local g = modelname.Arm2:Clone()
        g.Parent = Player.Character
        local C = g:GetChildren()
        for i=1, #C do
            if C[i].className == "Costume" then
                local W = Instance.new("Weld")
                W.Part0 = g.Middle
                W.Part1 = C[i]
                local CJ = CFrame.new(g.Middle.Position)
                local C0 = g.Middle.CFrame:inverse()*CJ
                local C1 = C[i].CFrame:inverse()*CJ
                W.C0 = C0
                W.C1 = C1
                W.Parent = g.Middle
            end
                local Y = Instance.new("Weld")
                Y.Part0 = Player.Character["Right Arm"]
                Y.Part1 = g.Middle
                Y.C0 = CFrame.new(0, 0, 0)
                Y.Parent = Y.Part0
        end

        local h = g:GetChildren()
        for i = 1, # h do
            h[i].Anchored = false
            h[i].CanCollide = false


    end -- check if using morph
end -- function end
end
end
end
end
end
end
end
end
end
end

-- [[ CONNECTIONS ]] --

Remote.OnServerEvent:Connect(MorphHandler)

What am i doing wrong? I've checked in play mode the "UsingMorph" value is in the character from the GUI giving it to player on click but still the error shows up.

0
are you giving the UsingMorph value locally and not serversided? Donut792 216 — 4y
0
No its serversided. HannahToots 4 — 4y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
4 years ago

Simple solution. More than likely, you have FilteringEnabled on, which is a good thing, and since you stated it's ServerSided, here's what I feel may be happening:

You said the GUI puts the BooleanValue inside the character. It would be visible client sided, but not server sided. To have it visible from the Server, you'd need to use a RemoteEvent/RemoteFunction to tell the server to put that value inside of the character so it can see it.

1
She already has the RemoteEvent set up, she just needs to pass it the value. Her function should be MorphHandler(Player, useMorph), and she should just send the bool with MorphRemote:FireServer(useMorph). No need for a BoolValue object at all. EmilyBendsSpace 1025 — 4y
0
That works as well. I was more going with the methods she already used, since it'd most likely be more comfortable. +1 For the comment Shawnyg 4330 — 4y
Ad

Answer this question