How can I implement a WO system inside of my KDR system?

Hello there.

I’m trying to recreate a simple KDR system. I’m already done with the KO part, just I don’t know how to implement the WO part since I don’t want players resetting to get a WO point.

game:GetService("Players").PlayerAdded:Connect(function(Plr)
	local leaderstats = Instance.new("Folder",Plr)
	leaderstats.Name = "leaderstats"
	
	local KOStats = Instance.new("IntValue",leaderstats)
	KOStats.Name = "KO"
	local WOStats = Instance.new("IntValue",leaderstats)
	WOStats.Name = "WO"
	
	Plr.CharacterAdded:Connect(function(Char)
		local Humanoid = Char:FindFirstChildWhichIsA("Humanoid")
		Humanoid.Died:Connect(function()
			local Tag = Humanoid:FindFirstChild("creator")
			if Tag then
				local Plr = Tag.Value
				
				Plr.leaderstats.KO.Value += 1
			end
		end)
	end)
end)
2 Likes
Humanoid.Died:Connect(function()
	local Tag = Humanoid:FindFirstChild("creator")
	if Tag then
		local Plr = Tag.Value
		Plr.leaderstats.KO.Value += 1
		WOStats.Value += 1 -- Just add one WO here
	end
end)
2 Likes

If you don’t want them to use reset, the easiest solution is to use StarterGui:SetCore() like this:

game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
1 Like

This needs to be on the client, but a better solution would be to replace false in SetCore() with a function that fires a remote event to the server to reset them without killing them. This would still allow them to reset, but it would stop them from using it to farm wipeouts.

3 Likes

Wait so it’s possible to send functions when the player resetted without having to use Humanoid.Died()? Alright then.

2 Likes

Oh and by the way, can you give me an example on how?

1 Like

I tested this with a kill brick and manually resetting, and it worked.

LocalScript:

local resetBindable = Instance.new("BindableEvent")

local coreCall do
	local MAX_RETRIES = 8

	local StarterGui = game:GetService('StarterGui')
	local RunService = game:GetService('RunService')

	function coreCall(method, ...)
		local result = {}
		for retries = 1, MAX_RETRIES do
			result = {pcall(StarterGui[method], StarterGui, ...)}
			if result[1] then
				break
			end
			RunService.Stepped:Wait()
		end
		return unpack(result)
	end
end

resetBindable.Event:Connect(function()
	resetEvent:FireServer()
end)

coreCall("SetCore", "ResetButtonCallback", resetBindable)

Script (Server):

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)

		local Humanoid = character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			-- do KO stuff and everything else
			if Humanoid:GetAttribute("Reset") then return end
			-- do ONLY WO stuff
		end)
	end)
end)

resetEvent.OnServerEvent:Connect(function(player)
	local humanoid: Humanoid = player.Character:WaitForChild("Humanoid")
	humanoid:SetAttribute("Reset", true)
	humanoid.Health = 0
end)

By the way, the coreCall is a function that I found in this thread. Read through it for some more knowledge or if you’re confused why I used it.

1 Like

Found some issues.

1: For some reason, when a player dies, their WO’s disappear (I’d also assume their KO’s as well but I haven’t tested it yet) unless another players kills them which their WO’s will appear normally.
2: WO’s won’t appear on the victim’s screen.

1 Like

Send the updated code. This worked during testing, so it’s probably not in the right order,