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

Why is head not a valid member of model on line 35?

Asked by 4 years ago
Edited 4 years ago
local HolderFrame = script.Parent.Holder
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Trails = ReplicatedStorage.Trails

local player = game.Players.LocalPlayer
local character = player.Character



if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end

for i,v in pairs(HolderFrame:GetChildren()) do
    if v:IsA("TextButton") then
        v.MouseButton1Click:Connect(function()
            if v.Purchased.Value == false then
                if player.leaderstats.Points.Value >= v.Cost.Value then
                    player.leaderstats.Points.Value = player.leaderstats.Points.Value - v.Cost.Value
                    v.Purchased.Value = true
                    v.Status.Text = "Purchased"
                else
                    print("Not Enough")
                end
            elseif v.Purchased.Value == true then
                if not character:FindFirstChild(v.Name) then
                    for i,v in pairs(character:GetChildren()) do
                        if v:IsA("Trail") then
                            v:remove()
                        end
                    end
                local trail = v.Name
                local trailCopy = Trails[trail]:Clone()
                trailCopy.Parent = character
                trailCopy.Attachment0 = character.Head.At1
                trailCopy.Attachment1 = character.HumanoidRootPart.At2
                end
            end
        end)
    end
end

0
it worked xTheodxre 16 — 4y

Answer this question