I made a module script for using weapons but no matter what I try, the animation won’t play, I have permissions for it and there are no errors in the output. Also, I am pretty sure there are no other animations playing and the animation controller is there
local rep = game:GetService("ReplicatedStorage")
local remotes = rep:WaitForChild("RemoteEvents")
local damageEffect = remotes:WaitForChild("DamageEffect")
local misc= rep:WaitForChild("Misc")
local hitbox = misc:WaitForChild("Hitbox")
local Melee = {}
function Melee.Attack(plr,weapon)
local char = plr.Character
if not char then return end
local hum = char:FindFirstChild("Humanoid")
if not hum then return end
local track = hum.Animator:LoadAnimation(weapon.Animation)
track.Priority = Enum.AnimationPriority.Action
track:Play()
local sound = Instance.new("Sound",char)
sound.SoundId = weapon.SwingSoundID
sound:Play()
local sound2 = Instance.new("Sound",char)
sound2.SoundId = weapon.HitSoundID
local hrp = char.PrimaryPart
local newHitbox = hitbox:Clone()
task.wait(track.Length/2)
newHitbox.CFrame = hrp.CFrame * CFrame.new(0,0,-newHitbox.Size.Z/2)
newHitbox.Parent = workspace
local parts = workspace:GetPartsInPart(newHitbox)
local humanoidsHit = {}
for _, hit in parts do
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and humanoid ~= hum and not table.find(humanoidsHit,humanoid) and not game.Players:GetPlayerFromCharacter(hit.Parent) then
table.insert(humanoidsHit,humanoid)
humanoid:TakeDamage(weapon.Damage)
damageEffect:FireClient(plr,hit.Parent)
if not sound2.IsPlaying then
sound2:Play()
end
end
end
sound.Ended:Once(function()
sound:Destroy()
end)
newHitbox:Destroy()
end
return Melee
first of all, format the code, don’t expect any bit of help when you can’t even put any bit of effort into detailed topic, see you next 15 views later.
Where is this script located, server or client.
Is the weapon an actual ‘Tool’ class?
Are you sure the logic is getting to the Play location in the script, such as did you put a print(“hi”) statement to see if its actually reaching that point?
I think I see “FireClient” in there, if this is an animation being played on the character, it really needs to be played client side.
It is a module in replicated storage but the function is fired by the server, and weapon is just a configuration with all the information, also I think it gets to the play part because i hear the sound
So I need to play it on client side, there isnt any way to play it on server and other players probably cant see it right when i play it on the client?
I have this local script here that im using to play the animation, here it is
i did what you said and it still wont play, im on r6 and the animation is r6 so its not that, also track.IsPlaying returns true
local rep = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local remotes = rep:WaitForChild("RemoteEvents")
local configurations = rep:WaitForChild("Configurations")
local weapons = configurations:WaitForChild("Weapons")
local meleeConfig = weapons:WaitForChild("Melee")
local rangedConfig = weapons:WaitForChild("Ranged")
local attack = remotes:WaitForChild("WeaponAttack")
local equip = remotes:WaitForChild("EquipWeapon")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local gui = script.Parent
local weaponUi = gui.RightShop.Weapon
local image = weaponUi.WeaponImage
local damage = weaponUi.Damage
local hitspeed = weaponUi.Hitspeed
local currentWeapon = nil
uis.InputBegan:Connect(function(input,gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
local info = require(meleeConfig:FindFirstChild(currentWeapon))
if not info then
info = require(rangedConfig:FindFirstChild(currentWeapon))
end
local track = char.Humanoid.Animator:LoadAnimation(info.Animation)
track.Priority = Enum.AnimationPriority.Action
--load animation here
while track.Length == 0 do task.wait() end
--play animation here
track:Play()
print(track.IsPlaying)
attack:FireServer(currentWeapon)
end
end)
local function equipWeapon(weaponName)
equip:FireServer(weaponName)
local info = require(meleeConfig:FindFirstChild(weaponName))
if not info then
info = require(rangedConfig:FindFirstChild(weaponName))
end
if not info then return end
currentWeapon = weaponName
image.Image = info.Icon
damage.Text = tostring(info.Damage).." ⚔️"
hitspeed.Text = tostring(info.HitSpeed).." ⏰"
end
equipWeapon("Rusty Pipe")
I found a solution, I saw a video on youtube to change my game from r15 to r6 but it only changed the animation packs so it looked like r6 but was r15 the whole time