How can I make the pets move faster?

Howdy! So, I followed a pet system on youtube on how to make a pet system because I am not so good at making pet systems, and I was wondering how I can make the pet faster. The local script seemed like it made it moved. I tried changing stuff in the Moving Pets section, and it only changed the angle of the pet. Help would be appreciated, thanks!

Local Script (StarterGui):

local rs = game:GetService("ReplicatedStorage")
local pets = rs:WaitForChild("Pets")
local remotes = rs:WaitForChild("RemoteEvents")
local config = require(rs:WaitForChild("CONFIGURATION"))

local plr = game.Players.LocalPlayer

local mouse = plr:GetMouse()

local char = plr.Character
local equipped = char:WaitForChild("EQUIPPED PETS")


--Moving Pets
local maxAngle = 120

game:GetService("RunService").Heartbeat:Connect(function()
	
	if char and char.Humanoid.Health > 0 then

		local numPets = #char["EQUIPPED PETS"]:GetChildren()
		local degreesIncrement = maxAngle / (numPets-1)

		for petNum, pet in pairs(char["EQUIPPED PETS"]:GetChildren()) do

			local deg = (petNum-1)*degreesIncrement - 90 + (180-maxAngle)/2
			if numPets == 1 then
				deg = 0
			end

			local goalCF = char:FindFirstChild("UpperTorso") and char.UpperTorso.CFrame or char:FindFirstChild("Torso") and char.Torso.CFrame or char.HumanoidRootPart.CFrame
			goalCF = goalCF * CFrame.Angles(0, math.rad(deg), 0)
			goalCF = (goalCF - goalCF.LookVector * 6)
			goalCF = goalCF * CFrame.Angles(0, -math.rad(deg), 0)

			pet.PrimaryPart.AlignPosition.Position = goalCF.Position
			pet.PrimaryPart.AlignOrientation.CFrame = goalCF
		end
	end
end)


--Inventory Gui
local petsInventory = plr:WaitForChild("PetsInventory")
local petsEquipped = plr:WaitForChild("PetsEquipped")

local invGui = script.Parent:WaitForChild("PetInventoryGui");invGui.Enabled = true
local invFrame = invGui:WaitForChild("PetInventory");invFrame.Visible = false
local inventoryFrame = invFrame:WaitForChild("InventoryFrame")
local selectFrame = inventoryFrame:WaitForChild("SelectedPetFrame");selectFrame.Visible = false
local equippedFrame = invFrame:WaitForChild("EquippedFrame")
local closeInvButton = invFrame:WaitForChild("CloseButton")
local openInvBtn = invGui:WaitForChild("OpenButton")

function setupPetFrame(petFrame:Frame, pet:Model)
	petFrame.PetImage:ClearAllChildren()
	
	petFrame.PetName.Text = pet.Name
	petFrame.PetName.TextColor3 = config.RarityColor[pet.Parent.Name]
	
	local petModel = pet:Clone()
	petModel:PivotTo(CFrame.new())
	petModel.Parent = petFrame.PetImage
	
	local vpfCamera = Instance.new("Camera")
	vpfCamera.CFrame = CFrame.new(petModel:GetExtentsSize()*Vector3.new(0.6, -0.2, -2.1), Vector3.new(-0.25, 0, 0))--0.6, -0.2, -0.9
	petFrame.PetImage.CurrentCamera = vpfCamera
	vpfCamera.Parent = petFrame.PetImage
	
	petFrame.PetName.Visible = true
	petFrame.PetImage.Visible = true	
end

function createEquippedFrames()
	
	local equippedValues = petsEquipped:GetChildren()
	table.sort(equippedValues, function(a, b)
		return tonumber(a.Name) < tonumber(b.Name)
	end)
	
	for _, equippedValue in pairs(equippedValues) do
		local newFrame = script:WaitForChild("PetFrameEquipped"):Clone()
		
		if not equippedValue.Value then
			newFrame.PetName.Visible = false
			newFrame.PetImage.Visible = false
			
		else
			setupPetFrame(newFrame, equippedValue.Value)
		end
		
		equippedValue:GetPropertyChangedSignal("Value"):Connect(function()
			if equippedValue.Value then
				setupPetFrame(newFrame, equippedValue.Value)
			else
				newFrame.PetName.Visible = false
				newFrame.PetImage.Visible = false
			end
		end)
		
		newFrame.MouseButton1Click:Connect(function()
			if equippedValue.Value then
				selectFrame.Visible = false
				remotes:WaitForChild("UnequipPet"):FireServer(equippedValue.Name)
			end
		end)
		
		newFrame.Parent = equippedFrame.PetsContainer
	end
end

function updateInv()
	
	local petFrames = {}
	
	for _, pet in pairs(petsInventory:GetChildren()) do
		local newFrame = script.PetFrameInventory:Clone()
		
		newFrame.MouseButton1Click:Connect(function()
			selectFrame.PetName.Text = pet.Value.Name
			selectFrame.AnchorPoint = Vector2.new(0, 0)
			selectFrame.Position = UDim2.new(0, mouse.X - selectFrame.Parent.AbsolutePosition.X, 0, mouse.Y - selectFrame.Parent.AbsolutePosition.Y)
			selectFrame.Visible = true
		end)
		
		setupPetFrame(newFrame, pet.Value)
		
		table.insert(petFrames, {newFrame, pet.Value})
	end
	
	table.sort(petFrames, function(a, b)
		return 
			table.find(config.RarityOrder, a[2].Parent.Name) > table.find(config.RarityOrder, b[2].Parent.Name)
			or table.find(config.RarityOrder, a[2].Parent.Name) == table.find(config.RarityOrder, b[2].Parent.Name)
			and a[2].Name < b[2].Name
	end)
	
	for _, child in pairs(inventoryFrame.PetsContainer:GetChildren()) do
		if child.ClassName == script:WaitForChild("PetFrameInventory").ClassName then
			child:Destroy()
		end
	end
	
	for _, petFrame in pairs(petFrames) do
		petFrame[1].Parent = inventoryFrame.PetsContainer
	end
end

openInvBtn.MouseButton1Click:Connect(function()
	invFrame.Visible = not invFrame.Visible
end)
closeInvButton.MouseButton1Click:Connect(function()
	invFrame.Visible = false
end)

selectFrame.EquipButton.MouseButton1Click:Connect(function()
	remotes.EquipPet:FireServer(selectFrame.PetName.Text)
	selectFrame.Visible = false
end)
selectFrame.DeleteButton.MouseButton1Click:Connect(function()
	remotes.DeletePet:FireServer(selectFrame.PetName.Text)
	selectFrame.Visible = false
end)

mouse.Button1Up:Connect(function()
	selectFrame.Visible = false
end)

createEquippedFrames()
updateInv()

petsInventory.ChildAdded:Connect(updateInv)
petsInventory.ChildRemoved:Connect(updateInv)


--Viewing Incubator
local incubatorGui = script.Parent:WaitForChild("PetIncubatorGui");incubatorGui.Enabled = false
local incubatorFrame = incubatorGui:WaitForChild("PetIncubator");incubatorFrame.Visible = false
local incubatorCloseBtn = incubatorFrame:WaitForChild("CloseButton")
local incubatorBuyBtn = incubatorFrame:WaitForChild("BuyButton")

local currentIncubator = nil

incubatorCloseBtn.MouseButton1Click:Connect(function()
	incubatorFrame.Visible = false
	currentIncubator = nil
end)

incubatorBuyBtn.MouseButton1Click:Connect(function()
	if currentIncubator then
		remotes:WaitForChild("HatchPet"):FireServer(currentIncubator)
	end
end)

remotes:WaitForChild("ViewIncubator").OnClientEvent:Connect(function(incubator)
	
	currentIncubator = incubator
	
	incubatorFrame.IncubatorName.Text = incubator.Name .. " Egg"

	local incubatorConfig = require(incubator.Configuration)
	local hatchablePets = incubatorConfig.HatchablePets
	
	local petFrames = {}
	
	for _, pet in pairs(hatchablePets) do
		local foundPet = pets:FindFirstChild(pet, true)
		if foundPet then
			
			local newFrame = script.PetFrameIncubator:Clone()

			setupPetFrame(newFrame, foundPet)

			table.insert(petFrames, {newFrame, foundPet})
		end
	end

	table.sort(petFrames, function(a, b)
		return 
			table.find(config.RarityOrder, a[2].Parent.Name) > table.find(config.RarityOrder, b[2].Parent.Name)
			or table.find(config.RarityOrder, a[2].Parent.Name) == table.find(config.RarityOrder, b[2].Parent.Name)
			and a[2].Name < b[2].Name
	end)

	for _, child in pairs(incubatorFrame.PetsContainer:GetChildren()) do
		if child.ClassName == script.PetFrameIncubator.ClassName then
			child:Destroy()
		end
	end

	for _, petFrame in pairs(petFrames) do
		petFrame[1].Parent = incubatorFrame.PetsContainer
	end
	
	local rarities = {}
	for rarityName, chance in pairs(incubatorConfig.Chances) do
		table.insert(rarities, {rarityName, chance})
	end
	table.sort(rarities, function(a, b)
		return table.find(config.RarityOrder, a[1]) < table.find(config.RarityOrder, b[1])
	end)
	
	local raritiesText = " "
	for _, rarity in pairs(rarities) do
		local color = config.RarityColor[rarity[1]]
		color = {R = math.round(color.R*255); G = math.round(color.G*255); B = math.round(color.B*255)}
		raritiesText = raritiesText .. '<font color="rgb(' .. color.R .. ',' .. color.G .. ',' .. color.B .. ')">' .. rarity[1] .. ': <b>' .. rarity[2] .. '%</b></font><br />'
	end
	incubatorFrame.RaritiesText.RichText = true
	incubatorFrame.RaritiesText.Text = raritiesText
	
	incubatorFrame.BuyButton.TextLabel.Text = "$" .. incubatorConfig.Price
	if incubatorFrame.BuyButton.TextLabel:FindFirstChild("Shadow") then
		incubatorFrame.BuyButton.TextLabel.Shadow.Text = "$" .. incubatorConfig.Price
	end
	
	incubatorFrame.Visible = true
	incubatorGui.Enabled = true
end)


--Pet Hatched
local hatchedGui = script.Parent:WaitForChild("PetHatchedGui");hatchedGui.Enabled = false
local hatchedFrame = hatchedGui:WaitForChild("PetHatched");hatchedFrame.Visible = false
local continueButton = hatchedFrame:WaitForChild("ContinueButton")

continueButton.MouseButton1Click:Connect(function()
	hatchedFrame.Visible = false
	hatchedGui.Enabled = false
end)

remotes:WaitForChild("HatchPet").OnClientEvent:Connect(function(petName)
	
	local foundPet = pets:FindFirstChild(petName, true)
	
	if foundPet then
		setupPetFrame(hatchedFrame:WaitForChild("PetFrame"), foundPet)
		
		incubatorFrame.Visible = false
		incubatorGui.Enabled = false
		hatchedFrame.Visible = true
		hatchedGui.Enabled = true
	end
end)

Make the Responsiveness of the AlignPosition inside the pet’s PrimaryPart Higher

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.