Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix script?

Asked by
Zerio920 285 Moderation Voter
10 years ago
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.

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. GoldenPhysics 474 — 10y
0
I tried elseif player.Character:FindFirstChild("Torso") then / but that removes both the legs and the torso. Zerio920 285 — 10y

1 answer

Log in to vote
-1
Answered by 10 years ago

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

0
-1 for using :remove(), also, this may destroy the arms. gskw 1046 — 10y
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." Chaserox 62 — 10y
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. Zerio920 285 — 10y
Ad

Answer this question