hi the title says it all, not too sure why this is happening and if someone could help it would be much appreciated. keep in mind my leaderstats script is much longer and complex i just copied the leaderstats part of it. thank u to those who are willing to help and will provide u with more information if needed while helping me.
leaderstats script
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local level = Instance.new("IntValue")
level.Name = "Level"
level.Value = 0
level.Parent = leaderstats
local XP = Instance.new("IntValue")
XP.Name = "XP"
XP.Value = 0
XP.Parent = leaderstats
local kills = Instance.new("IntValue", leaderstats)
kills.Name = "Kills"
kills.Value = 0
kills.Parent = leaderstats
damage script this is placed inside the weapon so whenever they attack they’re supposed to gain 1 kill on the leaderstats
script.Parent.Handle.Touched:Connect(function(touch)
if script.Parent.CanDamage.Value == true then
if not touch.Parent:FindFirstChild("Humanoid") then return end
script.Parent.CanDamage.Value = false
touch.Parent.Humanoid:TakeDamage(20)
if touch.Parent.Humanoid.Health < 1 then
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1
end
wait(1)
script.Parent.CanDamage.Value = true
end
end)