Not asking for you to optimize, just how I could improve on this
--[[Wait for pet]]--
plr = game.Players.LocalPlayer
wait(2)
char = plr.Character
char:WaitForChild("Pet")
pet = char:FindFirstChild("Pet")
petage, ownerPos, Owner, petexp = pet.Age, pet.ownerPos, pet.Owner,pet.EXP
pet.Name = plr.Name.."'s pet Age: "..petage.Value
xp_to_next_age = petexp.Value + 300
--[[Setting pets value]]--
Owner.Value = plr.Name
ownerPos.Value = char.Torso.Position
local get_to_owner = Instance.new("BodyPosition",pet.Head)
get_to_owner.position = ownerPos.Value - Vector3.new(0, 25, 5)
--[[Player moved]]--
co = coroutine.create(function()
while wait() do
ownerPos.Value = char.Torso.Position
get_to_owner.position = ownerPos.Value - Vector3.new(0, 25, pet.Head.Size.Z)
get_to_owner.maxForce = Vector3.new(pet.Head:GetMass() * 25^2, 40000, pet.Head:GetMass() * 25^2)
end
end)
coroutine.resume(co)
pet.Head.Touched:connect(function(p)
if p.Name == "Food" then
petexp.Value = petexp.Value + 5
p:Destroy()
if petexp.Value == xp_to_next_age then
xp_to_next_age = petexp.Value + 300
pet.Head.Size = pet.Head.Size + Vector3.new(1,1,1)
end
end
end)
Hibachi Man makes his daring escape, The Barbecue Belly Slide! |