Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Killbrick spinner doesn't kill the player?

I have 2 questions but lets talk about that at the end. My killbrick spinner does spin but doesn't deal damage. It is a spinner with some CylindricalConstraint thingy that can move the player. The killbrick in the spinner is named "Instant KillBrick" and I can't find anything wrong with it.

So here is the script I guess:

local Debounce = false

for _,v in pairs(workspace:GetDescendants()) do
	if v:IsA("BasePart") and v.Name == "Instant KillBrick" then
		v.Touched:Connect(function(hit) 
			if Debounce == false then
			Debounce = true
			local Player = hit.Parent:FindFirstChild("Humanoid")
				if Player then
					Player:BreakJoint()
					Debounce = false
				end
			end
		end)
        end
end

3 answers

✓ Accepted answer

You have to set Debound to true after detecting it is Player! Read your logic again. what happens if it touches non-humanoid ? it sets Debounce to true and that wont be changed again.

2 comments

0

It works!

0

not only that you also fixed my another problem that I can't explain it here

instead of all this create a function with an event called "Touched" so whenever its touched its gonna do something

local instantKillBrick = game.Workspace["Instant KillBrick"]
local divideBy = 3

instantKillBrick.Touched:Connect(function(hit)
	local player = hit.Parent:FindFirstChild("Humanoid")
	if player then
		player.Health -= divideBy
	end
end)

Making Brick Detector

Instead of using that method, try using mine!

Its simple! Follow This Tutorial:

1. Make A Kill Brick

You can use brick and color it red and set material to Neon!

2. Make A Folder

Make a folder in workspace, then name it yourself! Then put your Kill Brick inside of it.

3. Make A Kill Script

You can copy my script:

local KillBrick = workspace:FindFirstChild("Folder Name"):GetChildren() --Change Folder Name To Your Folder Name!
local Debounce = false
local Damage = 10 --Total of the damage!

while wait() do
	for i = 1, #KillBrick do
		KillBrick[i].Touched:Connect(function(Hit)
			if Hit.Parent:FindFirstChild("Humanoid")and Debounce == false then
				Debounce = true
                Hit.Parent.Humanoid.Health -= Damage
                wait(0.5) --Time of Working Again!
                Debounce = false
			end
		end)
	end
end

After That, Put it on ServerScriptService or Workspace!


Thats all you need to do!

Comment Down Bellow If You Find Any Problem!

Thank's for Reading!

1 comment

0

This does work but it will be performance heavy as it is creating a new touched event every wait.

This discussion is preserved as it was. New answers, comments, and votes are closed.