Help with leaderstats issue

What kinds of errors are you getting?

i made sure the scripts we’re working and still having errors

1 Like

What type of errors did you get?

there was this script which was cuasing all the issues. thank u for ur help!

And also I made a new script, because when I test my other script it doesn’t work somehow?

Anyways, here is the newly done script :

local Debounce = false

-- DON'T REMOVE THESE, LIKE SERIOUSLY
script.Parent:FindFirstChild("Humanoid").Health -= script.Parent:FindFirstChild("Humanoid").MaxHealth
script.Parent:FindFirstChild("Humanoid").Health += script.Parent:FindFirstChild("Humanoid").MaxHealth

while task.wait() do
	local Players = game:GetService("Players")
	
	local Character = script.Parent -- Your mob/character
	local Humanoid = Character.Humanoid
	
	Humanoid.Died:Connect(function()
		if Debounce ~= true then
			Debounce = true
			
			for _, Player in pairs(Players:GetPlayers()) do
				-- Check if the player's character isn't nil
				if Player.Character ~= nil then
					-- Get the mob's/character's HumanoidRootPart, same as for the player's character
					local CharHumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
					local HumanoidRootPart = Player.Character:FindFirstChild("HumanoidRootPart")

					-- Get the distance between CharHumanoidRootPart and HumanoidRootPart
					local distance = (CharHumanoidRootPart.Position - HumanoidRootPart.Position).Magnitude

					if distance < 10 then -- Check if the distance is lower than 10 studs
						local Leaderstats = Player:FindFirstChild("leaderstats")

						-- Increase Kills by 1, and Points by 2
						Leaderstats:FindFirstChild("Kills").Value += 1
						Leaderstats:FindFirstChild("Points").Value += 2

						task.wait(.05)

						Debounce = false
					end
				end
			end
		end
	end)
end

Edit : I forgot to change some stuff.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.