Help needed with revenge system

So i’m trying to add a revenge system and I have it so that when you get killed you get a death screen with the option to take revenge and kill them. However I can’t figure out how i would do this. But i did try this:

Here are the scripts:

serverscript:

-- Rest of the code

local Revenged = RevengeRemoteFunction:InvokeClient(enemyPlayer, plr)
	if Revenged == true then
		Humanoid.Health = 0										
	end

-- Rest of the code

local script:

revengeButton.MouseButton1Click:Connect(function()
	buttonpressedRevenge = true
	MPS:PromptProductPurchase(localplayer, RevengeProductId)
end)

for i = 50, 0, -1 do
      --Here is the timer for how much seconds/10 you have to revenge

		Revenge_RF.OnClientInvoke = function(plrToRevenge)
			revengeDesc.Text = "Take revenge on: "..plrToRevenge.Name
			if buttonpressedRevenge and localplayer:GetAttribute("BoughtRevenge") then
				localplayer:SetAttribute("BoughtRevenge", false)
				soundGuiGroup:WaitForChild("Revenge"):Play()
				Frame.Visible = false
                buttonpressedRevenge = false
				return true
			end
		end

--Rest of the code for the timer
end

Sorry if the script is kinda bad lol.

You should make it so when they buy the revenge developer product, it fires a remote event to the server, instead of having the onclientinvoke, just use FireServer() and onserverevent.

Are you getting any errors when you run the code?

1 Like

I could try that but how can I get the name of the player who he wants to kill? And for the errors, I’m not getting any errors when I die the revenge description says: “Take revenge on: [player name]” and when i click on the button it prompts but when i buy it nothing happends. Is it maybe because it onclient invoke checks the statements once and when they are not true it just goes on?

Nevermind guys i fixed it. The problem was that the invokeclient just checked once and not every 0.1 seconds until the timer ended

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