Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to cast Instance to CoordinateFrame?

I made a model and I am trying to position it on the player. I don't how to fix this error I keep on getting this error that says

Unable to cast Instance to CoordinateFrame

I don't know what it is. Here is my script I don't know what I am doing wrong.

local Lighting = game.Lighting
local Vest = Lighting:WaitForChild("Flak Jacket")


game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("UpperTorso")

        local ClonedVest = Vest:Clone()
        ClonedVest.Parent = character

        ClonedVest:SetPrimaryPartCFrame(character:WaitForChild("UpperTorso"))

        local Weld = Instance.new("Weld")
        Weld.Part0 = ClonedVest.Main
        Weld.Part1 = character:WaitForChild("UpperTorso")
        Weld.Parent = character:WaitForChild("UpperTorso")
        ClonedVest:SetPrimaryPartCFrame(ClonedVest:GetPrimaryPartCFrame() * CFrame.new(0,0,5))
    end)
end)

2 comments

0

The error puts in on line 12

2

you forgot to put a .CFrame after character:WaitForChild("UpperTorso")

1 answer

✓ Accepted answer

You forgot to define the cframe

local Lighting = game.Lighting
local Vest = Lighting:WaitForChild("Flak Jacket")


game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("UpperTorso")

        local ClonedVest = Vest:Clone()
        ClonedVest.Parent = character

        ClonedVest:SetPrimaryPartCFrame(character:WaitForChild("UpperTorso").CFrame)

        local Weld = Instance.new("Weld")
        Weld.Part0 = ClonedVest.Main
        Weld.Part1 = character:WaitForChild("UpperTorso")
        Weld.Parent = character:WaitForChild("UpperTorso")
        ClonedVest:SetPrimaryPartCFrame(ClonedVest:GetPrimaryPartCFrame() * CFrame.new(0,0,5))
    end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.