My pet just flies somewhere and I cant find it in the players character, can anyone help?
eventFolder.EquipPet.OnServerEvent:Connect(function(player, pet)
if player then
local character = player.Character
if character then
local humRootPart = character.HumanoidRootPart
local newPet = pet:Clone()
newPet.Parent = character
local representivePet = Instance.new("ObjectValue", newPet)
representivePet.Value = pet
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
wait(0.05)
while (representivePet.Value.Parent == player.EquippedPets and wait()) do
for i, v in pairs(representivePet.Value.Parent:GetChildren()) do
if v == representivePet.Value then
if i == 1 then
bodyPos.Position = humRootPart.Position + Vector3.new(0, 4, 4)
bodyGyro.CFrame = humRootPart.CFrame
elseif i == 2 then
bodyPos.Position = humRootPart.Position + Vector3.new(3, 3, 4)
bodyGyro.CFrame = humRootPart.CFrame
elseif i == 3 then
bodyPos.Position = humRootPart.Position + Vector3.new(-3, 3, 4)
bodyGyro.CFrame = humRootPart.CFrame
end
end
end
end
newPet:Destroy()
end
end
end)
local pet = -- define your pet here
local HumanoidRootPart = --define root part here
local TWS = game:GetService("TweenService")
game["Run Service"].RenderStepped:Connect(function()
local cf = HumanoidRootPart.CFrame + CFrame.new(10,10,10)
TWS:Create(pet, TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = cf}):Play()
end)
You’re making things too complicated in my opinion.
It will work on the server side too, but it’s much smoother on the client side. Also make sure to turn off collisions on the pet so it will be even more smoother.
That’s really weird, I just tried the following script and it worked perfectly fine:
local pet = game.ReplicatedStorage.Assets.Pets.Immortals.Dragon
local tws = game:GetService("TweenService")
local info = TweenInfo.new(.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local clone = pet:Clone()
clone.Parent = char
clone.CanCollide = false
clone.Massless = true
clone.CanTouch = false
while task.wait() do
local cf = char.PrimaryPart.CFrame * CFrame.new(6,0,5)
tws:Create(clone, info, {CFrame = cf}):Play()
end