- What do you want to achieve?
Currently have a script that gives a player a pet and has it floating near it shoulder. I wanted to know 2 things: if the way this pet system is set up as far as how the code makes the pet follow you and float is correct, recommended, and/or conventional? And also wondering how I would make the pet slowly float up and down gently like a cute animation. I don’t exactly want to give each pet a head and torso and rig to give it an actual animation, but rather would like it to be just be tweened or coded in? Have no clue how I would go on about this
- What is the issue?
Currently not sure if the wait() part is recommended, and also not sure if the way the code sets up the pet following is correct/recommended
Any tips, extra info, or help on anything and on making the pet float up and down gently.
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)
newPet.CanCollide = false
while wait() do
bodyPos.Position = humRootPart.Position + Vector3.new(3, 3, 4)
bodyGyro.CFrame = humRootPart.CFrame
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
givePet(player)
end)
end)