Button to make the player be able to kill someone only works once

  1. What do you want to achieve? I want my button to make the player go “angry” and be able to kill players when they are angry.

  2. What is the issue? This button only works once for some reason.

  3. What solutions have you tried so far? I looked it up on the Dev Forum and they did not have my problem.

local rs = game:GetService("ReplicatedStorage")
rs:WaitForChild("MakeAngry").OnServerEvent:Connect(function(plr)
	plr:WaitForChild("leaderstats"):WaitForChild("Anger Triggered").Value = plr:WaitForChild("leaderstats"):WaitForChild("Anger Triggered").Value + 1
	plr:WaitForChild("canHurt").Value = true
	local angryb = rs:WaitForChild("angry"):Clone()
local char = plr.Character or plr.CharacterAdded:Wait()
	local faceclone = char.Head.face:Clone()
	char.Head.face.Color3 = Color3.fromRGB(255,0,0)
	char.Head.face:Destroy()
	angryb.Parent = char.Head
	local decal = Instance.new("Decal",char.Head)
	decal.Texture = "rbxassetid://6481061697"
	local ogheadcolor = char.Head.BrickColor
	char:WaitForChild("Body Colors").HeadColor = BrickColor.new("Really red")
local torsofire = Instance.new("Fire",char:WaitForChild("Torso"))
torsofire.Heat = 14
	torsofire.Size = 5
	wait(plr:WaitForChild("cooldown").Value)
	plr:WaitForChild("canHurt").Value = false
	torsofire:Destroy()
	decal:Destroy()
	faceclone.Parent = char.Head
	char.Head.BrickColor = ogheadcolor
	angryb:Destroy()
	end)

This button makes the player angry and they can kill other players, but why does it only work once?

1 Like

Work only once meaning that after they become angry they can’t become angry again or can only kill a single person?

2 Likes

They cannot become angry again.

1 Like

Could it be that the RemoteEvent is only being ran once? What’s the code that contains the Firing of the event

1 Like
local debounce=  false
script.Parent.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
	local content = require(game:GetService("ReplicatedStorage"):WaitForChild("content"))
	if script.Parent:GetAttribute("ready") == true then
		local cooldown = 120
		script.Parent:SetAttribute("ready",false)
		local plr = game.Players.LocalPlayer
		local rs = game:GetService("ReplicatedStorage")
			rs:WaitForChild("MakeAngry"):FireServer(plr)
			wait(40)
			debounce = false
			end
	end
end)
1 Like

Okay so the issue that I see in that script is that nothing sets the ready Attribute back to true, meaning that it’s only gonna run once. You need to put somewhere in the script you just sent me a line to set it back to true. Because if it’s false when you press the button, it basically softlocks the button. Maybe try

local debounce=  false
script.Parent.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		local content = require(game:GetService("ReplicatedStorage"):WaitForChild("content"))
		if script.Parent:GetAttribute("ready") == true then
			local cooldown = 120
			script.Parent:SetAttribute("ready",false)
			local rs = game:GetService("ReplicatedStorage")
			rs:WaitForChild("MakeAngry"):FireServer()
			wait(40)
			debounce = false
			script.Parent:SetAttribute("ready", true)
		end
	end
end)

Edit: Removed references to the plr obj since A RemoteEvent related to server automatically gets that passed in

Thank you so much. It is working fine now!

1 Like

Anytime! If you have any issues don’t be afraid to make another post!

1 Like