Yes ik its gpt trust me ive gone through this code as best as I can Im still a beginner tho
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
-- Wait for the local player
local player = Players.LocalPlayer
-- Wait for the character to exist
local character = player.Character or player.CharacterAdded:Wait()
-- Wait for Humanoid to exist
local humanoid = character:WaitForChild("Humanoid")
-- Ensure Animator exists
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Parent = humanoid -- MUST be under Humanoid
end
local anim = ReplicatedStorage:WaitForChild("Test")
-- Optional: Stop other R6 animations to avoid conflicts
local function stopOtherAnimations()
for _, a in pairs(humanoid:GetPlayingAnimationTracks()) do
a:Stop()
end
end
-- Key press detection
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.E then
print("E pressed! Playing punch animation.")
stopOtherAnimations() -- stop conflicting animations
-- Load the animation (make sure this Animation object exists in ReplicatedStorage)
local track = animator:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action4
track:Play() -- play punch animation
end
end)
everythign else works correctly, do I need to stop other animations before playing my own?
** You are now Level 4! **