Getting tons of glitches with the pets glitching out a ton, and I’ve seen it myself.
I’ve looked over the dev wiki, but I didn’t see any solutions…
(The pets are models that lerp every frame to their target CFrame)
Can anybody help me out here?
local Player = game.Players.LocalPlayer
local Bounce = Instance.new("NumberValue")
Bounce.Value = 0
local mode = "up"
local touchEnabled = game:GetService("UserInputService").TouchEnabled
local function UpdatePets()
if mode == "up" then
Bounce.Value = Bounce.Value + 0.05
elseif mode == "down" then
Bounce.Value = Bounce.Value - 0.05
end
if Bounce.Value >= 0.75 then
mode = "down"
elseif Bounce.Value <= -0.5 then
mode = "up"
end
if touchEnabled then
for i,v in pairs(game.Players:GetPlayers()) do
if v ~= game.Players.LocalPlayer then
local Character = v.Character
if Character then
for i,v in pairs(Character:GetChildren()) do
if v.Name == "GamePet" then
v:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,-1000,0)))
v.Name = "mobileUser"
end
end
end
end
end
local v = game.Players.LocalPlayer
local Character = v.Character
if Character then
local root = Character:FindFirstChild("HumanoidRootPart")
local humanoid = Character:FindFirstChild("Humanoid")
if root and humanoid then
local list = {}
for i,GamePet in pairs(Character:GetChildren()) do
if GamePet.Name == "GamePet" then
table.insert(list,GamePet)
end
end
for i,GamePet in pairs(list) do
local info = TweenInfo.new(0.05,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
local newpos = root.CFrame.p
local newcf = CFrame.new(newpos)
newcf = newcf * CFrame.Angles(0,math.rad((360/#list)*i),0)
newcf = newcf + (newcf.lookVector*5) + Vector3.new(0,Bounce.Value,0)
newcf = CFrame.new(newcf.p,newcf.p + root.CFrame.lookVector)
if humanoid.MoveDirection == Vector3.new(0,0,0) then
newcf = CFrame.new(newcf.p,root.CFrame.p)
end
if GamePet then
GamePet.PrimaryPart = GamePet.MainPart
local new = GamePet:GetPrimaryPartCFrame():lerp(newcf,0.1)
GamePet:SetPrimaryPartCFrame(new)
end
end
end
end
else
for _,v in pairs(game.Players:GetPlayers()) do
local Character = v.Character
if Character then
local root = Character:FindFirstChild("HumanoidRootPart")
local humanoid = Character:FindFirstChild("Humanoid")
if root and humanoid then
local list = {}
for i,GamePet in pairs(Character:GetChildren()) do
if GamePet.Name == "GamePet" then
table.insert(list,GamePet)
end
end
for i,GamePet in pairs(list) do
local info = TweenInfo.new(0.05,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
local newpos = root.CFrame.p
local newcf = CFrame.new(newpos)
newcf = newcf * CFrame.Angles(0,math.rad((360/#list)*i),0)
newcf = newcf + (newcf.lookVector*5) + Vector3.new(0,Bounce.Value,0)
newcf = CFrame.new(newcf.p,newcf.p + root.CFrame.lookVector)
if humanoid.MoveDirection == Vector3.new(0,0,0) then
newcf = CFrame.new(newcf.p,root.CFrame.p)
end
if GamePet then
GamePet.PrimaryPart = GamePet.MainPart
local new = GamePet:GetPrimaryPartCFrame():lerp(newcf,0.1)
GamePet:SetPrimaryPartCFrame(new)
end
end
end
end
end
end
end
game:GetService("RunService").RenderStepped:Connect(UpdatePets)