You see where the pet animation function is , yea that function is not playing/ working and I wanted to know why
Server script
local CD = script.Parent -- click detector
local Hitbox = script.Parent.Parent
local Health = Hitbox.Parent.Health
game.Players.PlayerAdded:Connect(function(plr)
local function DetectClick(playerWhoClicked)
-- CD function
local amountequuippedvalue = plr.PlayerGui.Inventory.LowerInvFrame.AmountEquipped.AmountEquippedValue-- value used to track the specified amount of pets equipped
local character = playerWhoClicked.Character:GetChildren() or playerWhoClicked.CharacterAdded:Wait():GetChildren()-- getting char
for _,pet in pairs(character) do
if pet ~= nil then
if pet:IsA("Model") then
-- if can a print, it will print the pet name ex:Dragon
print("Pet Found")
pet:PivotTo(Hitbox.CFrame)
local alignPosition = pet:WaitForChild("AlignPosition")
local alignOrientation = pet:WaitForChild("AlignOrientation")
local attachmentpet = pet.PetHitBox:WaitForChild("Attachment")
local atttachmentTarget = Hitbox.Attachment
-- all these attachments and constrainst were created before hand
attachmentpet.Parent = pet.PrimaryPart
alignPosition.Attachment0 = attachmentpet
alignPosition.Attachment1 = atttachmentTarget
alignPosition.Parent = Hitbox
-- for positioning the pet
alignOrientation.Attachment0 = attachmentpet
alignOrientation.Attachment1 = atttachmentTarget
alignOrientation.Parent = Hitbox
-- for rotating the pet
if amountequuippedvalue.Value == 1 then
atttachmentTarget.Position = Vector3.new(0,0,4)
elseif amountequuippedvalue.Value == 2 then
atttachmentTarget.Position = Vector3.new(6,0,0)
atttachmentTarget.Orientation = Vector3.new(0,87,0)
elseif amountequuippedvalue.Value == 3 then
atttachmentTarget.Orientation = Vector3.new(0,185,0)
atttachmentTarget.Position = Vector3.new(0,0,-4)
elseif amountequuippedvalue.Value == 4 then
atttachmentTarget.Position = Vector3.new(-5,0,0)
atttachmentTarget.Orientation = Vector3.new(0,-90,0)
elseif amountequuippedvalue.Value == 5 then
atttachmentTarget.Position = Vector3.new(0,0,3)
local function petAnimation()
local atttachmentTarget = Hitbox.Attachment
while Health.Value <= 0 do
wait(1)
pet.CFrame = pet.CFrame + pet.CFrame.LookVector * 2
pet.CFrame = pet.CFrame + pet.CFrame.LookVector:Inverse() * 2
end
end
petAnimation()
end
end
else
print("There was a issue with the pet loading")
end
end
--search char for Groups
--remote event
-- pet in LOCAL SCRIPT transfers to SERVER SCRIPT(So everybody can see the pet attacks and animations, and for the player to get the coins )
--------------------------------
-- remote event code
-- step1: make pet pivot to chest, then make animations while damage is being done, and do if damage then coins pop and SFX tho and leaderstats
end
CD.MouseClick:Connect(DetectClick)
end)