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

How to fix script?

local deb = false

script.Parent.Touched:connect(function(h)
	if h.Parent:FindFirstChild("Humanoid") then
		if deb == true then return end
		deb = true
script.Parent.Sound4:Play()
		local player = game.Players:GetPlayerFromCharacter(h.Parent)
		if player.Character:FindFirstChild("Left Leg") or player.Character:FindFirstChild("Right Leg") then
			if player.Character:FindFirstChild("Left Leg") then
			player.Character["Left Leg"]:Destroy()
				end
			if player.Character:FindFirstChild("Right Leg") then
			player.Character["Right Leg"]:Destroy()
				end
		elseif player.Character:FindFirstChild("Left Leg") ~= nil and player.Character:FindFirstChild("Right Leg") ~= nil then
			player.Character.Torso:Destroy()
			end
	end
	deb = false
	end)

Touching this brick is supposed to destroy your legs, or if you don't have any, destroy your torso. It destroys your legs but the torso thing doesn't seem to work. Can't figure out what it might be.

2 comments

0

On line 16 you're checking if the left or right leg exists, when the point is that they don't exist. Instead you should just check if there is a torso and if there is, remove it.

0

I tried elseif player.Character:FindFirstChild("Torso") then / but that removes both the legs and the torso.

1 answer

Dude. Your making it way more complicated than it needs to be. like lol

local deb = false
function ontouched(hit)
	wait(1)
	if deb == false then
		deb = true
		hit:Remove()		
	end
	deb = false
end
script.Parent.Touched:connect(ontouched)

Put that in the block u want

3 comments

0

-1 for using :remove(), also, this may destroy the arms.

0

If you dont want :remove() then add destroy. and thanks for giving me -1 for giving yu what you asked for. "Touching this brick is supposed to destroy your legs, or if you don't have any, destroy your torso."

0

This isn't what I asked for. What if the brick touches both the legs and the torso? It'll remove them both then. What if it only touches the torso? It'll remove the torso but not the legs.

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