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

How do I make this remove limbs multiple times?

Asked by 5 years ago

I'm trying to make it so when a person sits on a seat and a button is pressed, a part comes from the ceiling (invisible) and removes limbs, it works a few times but then it just stops working.

local debounce = false

function onTouched(hit)
    if debounce == false then
        debounce = true
    local human = hit.Parent:FindFirstChild("Humanoid")
    local arm1 = hit.Parent:FindFirstChild("RightHand") 
    local arm2 = hit.Parent:FindFirstChild("RightLowerArm") 
    local head = hit.Parent:FindFirstChild("Head")
    local scream = Instance.new("Sound")
    scream.SoundId = "rbxassetid://147758618"
    scream.Volume = 2
    scream.MaxDistance = 250
    scream.EmitterSize = 10
    scream.PlayOnRemove = false
    if (human ~= nil) then 
        scream.Parent = head
        scream:Play()
        human.Health = 80
        arm2:Destroy()
        arm1:Destroy()
        wait(15)
        debounce = false
        end
    end
end

if (script.Parent ~= nil) and (script.Parent.className == "Part") then 
    connection = script.Parent.Touched:connect(onTouched)
end

Also, if there's a way to execute the script on the player whos sitting, then that would be easier. I don't understand how to find the player who is in the seat, and I know it's a better way to do it. So if you could help me either way then thanks.

2
to detect who is sitting, place inside the seat this: local player = script.Parent.Ocuppant.Parent Leamir 3138 — 5y
0
Okay CaptainAlien132 225 — 5y

Answer this question