How can I add points to leaderstats in this script?

So I made a simple gun in Roblox for one of my games, and every time that you kill someone, you get a point on the leaderboard for kills.

Script:

local db = true
local sound = script.Sound
local reload =script.Reload

script.Parent.Fire.OnServerEvent:Connect(function(player, mousePos)
	
	if db == true then
		db = false

		local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {player.Character}
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		
		local raycastResult = workspace:Raycast(script.Parent.Handle.Position, (mousePos - script.Parent.Handle.Position)*300, raycastParams)
		
		if raycastResult then
			local hitPart = raycastResult.Instance
			local model = hitPart:FindFirstAncestorOfClass("Model")
			
			if model then
				if model:FindFirstChild("Humanoid") then
					if model.Humanoid.Health == 100 then
						print("Shot")
						model.Humanoid.Health -= 100
						player.leaderstats.Kills += 1
						sound:Play()
						sound.Ended:Wait()
						reload:Play()
						reload.Ended:Wait()
						db = true
					end
				end
			end
		end
	end
end)

You can see that I tried to do this on line 25. I am not an expert with leaderstats and I am wondering if anyone could help.

You need to add .Value after Kills so it changes the value.

1 Like

Man, I should have looked at my script closer. This was a simple fix. Thanks for pointing it out.

1 Like