Add a function to this script that, when the player jumps, rotates the orientation of…
- User
Add a function to this script that, when the player jumps, rotates the orientation of the mesh skateequiped, which is inside the player, by 360 degrees smoothly in 0.3 seconds, and then returns to the X-axis orientation of 0. local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local player = Players.LocalPlayer local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local SkateEquipEvent = ReplicatedStorage:WaitForChild("SkateEquipEvent") local SkateUnequipEvent = ReplicatedStorage:WaitForChild("SkateUnequipEvent")
-- IDs das animações (substitua pelos seus IDs reais) local skateIdleAnimationId = "rbxassetid://18254030554" -- Substitua pelo ID da sua animação de parado no skate local skateMoveAnimationId = "rbxassetid://17363261325" -- Substitua pelo ID da sua animação de movimento no skate
-- Carregar as animações local skateIdleAnimation = Instance.new("Animation") skateIdleAnimation.AnimationId = skateIdleAnimationId
local skateMoveAnimation = Instance.new("Animation") skateMoveAnimation.AnimationId = skateMoveAnimationId
local skateIdleTrack local skateMoveTrack
local isOnSkate = false local movedConnection local stateConnection
local function updateAnimation() if isOnSkate then local state = humanoid:GetState() if state == Enum.HumanoidStateType.Jumping or state == Enum.HumanoidStateType.Freefall then -- Jogador está pulando ou caindo if skateIdleTrack and skateIdleTrack.IsPlaying then skateIdleTrack:Stop() end if skateMoveTrack and skateMoveTrack.IsPlaying then skateMoveTrack:Stop() end else -- Jogador não está pulando ou caindo local speed = humanoid.MoveDirection.Magnitude if speed > 0 then -- Jogador está se movendo if skateIdleTrack and skateIdleTrack.IsPlaying then skateIdleTrack:Stop() end if skateMoveTrack and not skateMoveTrack.IsPlaying then skateMoveTrack:Play() end else -- Jogador está parado if skateMoveTrack and skateMoveTrack.IsPlaying then skateMoveTrack:Stop() end if skateIdleTrack and not skateIdleTrack.IsPlaying then skateIdleTrack:Play() end end end end end
local function onSkateEquipped() if isOnSkate then return end
isOnSkate = true -- Desativa o script de animações padrão local animateScript = character:FindFirstChild("Animate") if animateScript then animateScript.Disabled = true end -- Para todas as animações atualmente em execução for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do track:Stop() end -- Inicia a animação de parado no skate skateIdleTrack = humanoid:LoadAnimation(skateIdleAnimation) skateIdleTrack.Priority = Enum.AnimationPriority.Action4 -- Definir prioridade para 'Action4' (mais alta) skateIdleTrack.Looped = true skateIdleTrack:Play() -- Prepara a animação de movimento no skate skateMoveTrack = humanoid:LoadAnimation(skateMoveAnimation) skateMoveTrack.Priority = Enum.AnimationPriority.Action4 -- Definir prioridade para 'Action4' (mais alta) skateMoveTrack.Looped = true -- Conecta aos eventos para atualizar as animações movedConnection = humanoid.Running:Connect(function(speed) updateAnimation() end) stateConnection = humanoid.StateChanged:Connect(function(oldState, newState) updateAnimation() end) - Assistant