There is something I have been struggling for quite a bit now. This is a script that manages the pet(s) following the player if it is equipped. The pet’s movement (before) was quite plain and looked like this-
https://gyazo.com/aa7178ce456efdf97b60b82ec6793c71
local Disabled = false
local Player = game.Players:FindFirstChild(script.Parent.Parent.Name)
if Player then
while wait() do
if Player.Character.Health ~= 0 then
if not Disabled then
local Pos = script.Parent.Pos.Value
local BG = script.Parent.PrimaryPart.BodyGyro
local BP = script.Parent.PrimaryPart.BodyPosition
local d = Player.Character.HumanoidRootPart.Position.Y - script.Parent.PrimaryPart.Position.Y
BP.Position = (Player.Character.HumanoidRootPart.Position + Pos) - Vector3.new(0,Player.Character.HumanoidRootPart.Size.Y/2,0) + Vector3.new(0,script.Parent.PrimaryPart.Size.Y/2,0) + Vector3.new(0,game.ServerScriptService.Pets.globalPetFloat.Value,0)
if Player.Data.isWalking.Value == false then
BG.CFrame = CFrame.new(script.Parent.PrimaryPart.Position, Player.Character.HumanoidRootPart.Position - Vector3.new(0, d, 0))
else
BG.CFrame = Player.Character.HumanoidRootPart.CFrame
end
else
script.Parent:Destroy()
break
end
else
Disabled = false
end
end
end
So I added on to the code and this is what I have at the moment-
https://gyazo.com/09c43a41f9dd64f1e7d7f482fe408c18
local Disabled = false
local Player = game.Players:FindFirstChild(script.Parent.Parent.Name)
local angle = 180
wait(.001)
if Player then
while wait(0.025) do
if angle >= 360 then
angle = 0
end
angle += 6
if Player.Character.Health ~= 0 then
if not Disabled then
local Pos = script.Parent.Pos.Value
local BG = script.Parent.PrimaryPart.BodyGyro
local BP = script.Parent.PrimaryPart.BodyPosition
local d = Player.Character.HumanoidRootPart.Position.Y - script.Parent.PrimaryPart.Position.Y
BP.Position = (Player.Character.HumanoidRootPart.Position + Pos) - Vector3.new(0,Player.Character.HumanoidRootPart.Size.Y/2,0) + Vector3.new(0,script.Parent.PrimaryPart.Size.Y/2,0) + Vector3.new(0,game.ServerScriptService.Pets.globalPetFloat.Value,0)
if Player.Data.isWalking.Value == false then
BG.CFrame = CFrame.new(script.Parent.PrimaryPart.Position, Player.Character.HumanoidRootPart.Position - Vector3.new(0, d, 0)) + Vector3.new(0, math.sin(math.rad(angle)), 0))
else
BG.CFrame = Player.Character.HumanoidRootPart.CFrame + Vector3.new(0, math.sin(math.rad(angle)), 0)
end
else
script.Parent:Destroy()
break
end
else
Disabled = false
end
end
end
I added the angle thing which makes it sort of look like Bubble Gum Simulator pets’ movement
https://gyazo.com/77b60bdd3d63e0029e9777ccb56b1cf9
__
My problem is that the addition I made only works when the player is idle or ‘isWalking = false’
I need help with figuring out how to make it do that swing/rotation while the player is walking but at the same time following the player + looking at the direction player is walking.
https://gyazo.com/fc6c59acb1b950ddba6622928b37bb13
Any help is appreciated!
Thank you for reading!