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

ServerScriptService.StandHandler:15: attempt to index nil with 'CFrame?'

Asked by 2 years ago
Edited 2 years ago

I'm trying to make a Jojo's Bizzare Adventure game and I made a stand handling script (a regular script) and when I click "Q" to summon this comes up in the output.

               **"ServerScriptService.StandHandler:15: attempt to index nil with 'CFrame.'**

Here is the whole StandHandler Script. PS the error is in line 15.

local TweenService = game:GetService("TweenService")

local mainFolder = game.ReplicatedStorage.StandFolder
local Summon = mainFolder.RemoteEvents.Summon

Summon.OnServerEvent:Connect(function(player, isActive)
    local char = player.Character
    local hrp = char.HumanoidRootPart

    if isActive == true then
        local Stand = mainFolder.Models.Stand:Clone()
        local mainPart = Stand.PrimaryPart

        Stand.Parent = char
        mainPart.CFrame = hrp.CFrame

        local weld = Instance.new("ManualWeld")
        weld.Name = "Weld"
        weld.Part0 = mainPart
        weld.Part1 = hrp
        weld.C0 = mainPart.CFrame:ToObjectSpace(hrp.CFrame)
        weld.Parent = weld.Part0

        for i, bodyPart in pairs(Stand:GetChildren()) do
            if bodyPart:IsA("BasePart") and bodyPart ~= mainPart then
                local info = TweenInfo.new(0.45)
                local goal = {Transparency = 0}

                local tween = TweenService:Create(bodyPart, info, goal)
                tween:Play()
            end
        end

        local info = TweenInfo.new(0.5)
        local goal = {}
        goal.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
        goal.C1 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame * CFrame.new(-3, 1.5, 3))

        local tween = TweenService:Create(weld, info, goal)
        tween:Play()

        local AnimControl = Stand.AnimationController
        local Idle = AnimControl:LoadAnimation(script.Animations.Idle)
        Idle:Play()
    else
        local Stand = char:WaitForChild("Stand")
        local mainPart = Stand.PrimaryPart

        if Stand then
            if Stand.PrimaryPart:WaitForChild("Weld") then
                local weld = Stand.PrimaryPart:WaitForChild("Weld")

                for i, bodyPart in pairs(Stand:GetChildren()) do
                    if bodyPart:IsA("BasePart") and bodyPart ~= mainPart then
                        local info = TweenInfo.new(0.45)
                        local goal = {Transparency = 1}

                        local tween = TweenService:Create(bodyPart, info, goal)
                        tween:Play()
                    end
                end

                local info = TweenInfo.new(0.5)
                local goal = {}
                goal.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
                goal.C1 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)

                local tween = TweenService:Create(weld, info, goal)
                tween:Play()

                tween.Completed:Connect(function()
                    Stand:Destroy()
                end)
            end
        end
    end
end)
0
Can you make sure that the HumanoidRootPart of the player isnt detected as nil, and the same for the primary part? Dexiber 272 — 2y

Answer this question