I’m trying to make an animation play whenever I click with a tool in my hand.
This works in Studio, but not in the published game.
Why is this happening?
The toolbox looks like this:
This is inside the “Attack” local script:
script.Parent.Equipped:Connect(function()
script.Parent.Equip:FireServer()
end)
And this is inside the normal “Attack” script inside the RemoteEvent:
local range = 3
local hitboxmodule = require(game.ReplicatedStorage.Hitboxes)
local dmgPerAttributePoint = 20
local starterDamage = 20
Enabled = true
local combo = 1
script.Parent.OnServerEvent:Connect(function(player)
if not Enabled then return end
local char = player.Character
Enabled = false
if combo == 1 then
local Anim = script.Swing1
local playAnim = char.Humanoid:LoadAnimation(Anim)
playAnim:Play()
combo = 2
else
local Anim = script.Swing2
local playAnim = char.Humanoid:LoadAnimation(Anim)
playAnim:Play()
combo = 1
end
local targets = hitboxmodule(char,range)
local dmg = starterDamage + player.Attributes.Attack.Value *dmgPerAttributePoint
for i,v in pairs(targets) do
v.Humanoid:TakeDamage(dmg)
if v.Humanoid.Health <= 0 then
v.Humanoid:Destroy()
local expToGain = 1
player.LevelsInfo.Experience.Value += expToGain
end
end
wait(1)
Enabled = true
end)
Thanks in advance for anyone who helps.