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

Why does it follow me when its a part but not a Model?

Asked by 3 years ago

Can any body help me? I'm having trouble making a Model follow me. I it works with a part, but I have a bee model and I want that to follow me, but it doesn't work. Can anybody tell me how I can fix it?

This is the script that I put in a part and it follows me:

local pet = script.Parent

function givePet (player)
    if player then
        local character = player.Character
        if character then
            local humRootPart = character.HumanoidRootPart
            local newPet = pet:Clone ()
            newPet.Parent = character

            local bodyPos = Instance.new("BodyPosition", newPet)
            bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

            local bodyGyro = Instance.new("BodyGyro", newPet)
            bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)

            while wait() do
                bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, 3)
                bodyGyro.CFrame = humRootPart.CFrame
            end
        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        givePet(player)
    end)
end)

But when I put that script in a model, it wont work. Can anybody tell me why?

0
Weld the model, I'd put Q perfection weld in the model greatneil80 2647 — 3y

1 answer

Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
3 years ago

Ok so you have a really easy problem here. I don't know if you you know this already, but in line 18, you cannot use vector 3 for models. You have to use CFrame, or MoveTo()

0
But I have a error then that says " Workspace.Model.Script:13: invalid argument #3 (Vector3 expected, got CFrame)", can you help me? Buzzettego 5 — 3y
0
And when I use MoveTo: Buzzettego 5 — 3y
0
hmm. So you know you have to do MoveTo(Vector3.new(x,y,z)) in order for it to work? Xyternal 247 — 3y
Ad

Answer this question