so, I’ve made my weapon using “raycasthitboxv4” melee kit and I also wanted to make it work with the leaderboard script.
I’ve tried adding creator value and tested it. the leaderboard did not work with this weapon, but other weapon like classic sword works. I tried many way to solve it but still it did not work. please help me.
(I’m bad at English so please forgive me) (the melee script is a normal script, not a localscript) (there are also no error in the output view)
here the script:
wait(0.1)
local plr = script.Parent.Parent.Parent
local char = plr.Character
local idle = char.Humanoid:LoadAnimation(script.Animations.Idle)
local equipped = false
local attacking = false
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(script.Parent.Weapon)
Hitbox.Visualizer = false
durability = 20
local attack1 = char.Humanoid:LoadAnimation(script.Animations.Attack1)
local broken = false
Hitbox.OnHit:Connect(function(hit, humanoid)
if humanoid.Parent ~= char and humanoid.Parent.Humanity.Value == false then
script.Parent.Weapon.Hit:Play()
local damage = 50
local Speed = 100
local Force = 100
local TotalForce = Force
local KnockBack = Instance.new("BodyVelocity",hit.Parent:FindFirstChild("Torso"))
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
KnockBack.Velocity = plr.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed -- based on the direction YOUR character is facing.
game.Debris:AddItem(KnockBack,0.1)
humanoid:TakeDamage(damage)
if Player then
local Tagged = Instance.new("ObjectValue")
Tagged.Name = "creator"
Tagged.Value = Player
Tagged.Parent = hit.Parent.Humanoid
game.Debris:AddItem(Tagged, 2)
end
if durability == 0 then
Hitbox:HitStop()
script.Parent.Weapon.Transparency = 1
script.Parent.Weapon.B:Play()
script.Parent.Weapon.ParticleEmitter:Emit(50)
game.ReplicatedStorage.EditGUI:FireClient(plr,"text","Your bat broke.")
broken = true
idle:Stop()
attack1:Stop()
wait(2)
script.Parent:Destroy()
end
durability = durability - 1
end
end)
script.Parent.Equipped:Connect(function()
if not plr.Character.Actions.Stunned.Value == true and not broken then
idle:Play()
equipped = true
end
end)
script.Parent.Unequipped:Connect(function()
idle:Stop()
equipped = false
end)
script.Parent.Activated:Connect(function()
if not attacking and equipped and not plr.Character.Actions.Stunned.Value == true and durability >= 0 then
attack1:Play()
attacking = true
script.Parent.Weapon.Prepare:Play()
wait(0.16)
Hitbox:HitStart()
script.Parent.Weapon.Swing:Play()
script.Parent.Weapon.Trail.Enabled = true
wait(0.4)
Hitbox:HitStop()
script.Parent.Weapon.Trail.Enabled = false
wait(1)
attacking = false
wait(0.4)
end
end)
plr.Character.Actions.Stunned.Changed:Connect(function()
plr.Character.Humanoid:UnequipTools()
end)