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

How would I fix this looped killing event?

Asked by 7 years ago
Edited 7 years ago

I have basically a large, non cancollided brick that takes over the map. Inside it are 4 scripts, one of them being inside a playable, working Sound. Another is called Projector, one that shows a hint when the other scripts are played. That one also works fine. The problem is the two remaining scripts, called Lava and Activator. Lava is basically this:

function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then
        humanoid.Health = 0
    end 
end

script.Parent.Touched:connect(onTouch)

Normally, this script works fine. The other script, called Activator, has the task to activate (de-disable) the Lava script in a re-occuring event.

while true do

wait(10)

script.Parent.Lava.Disabled = false

wait(1)

script.Parent.Lava.Disabled = true

wait(0.1)

end

Now, this event does work.. But only once. The output doesn't put much either, just acts like the script just is supposed to run once and never again. I'm sure it's something obvious, but I do not imagine there being scripts interfering with it, as I each name them individually. The weird thing is, the other two scripts run fine, and re-occur periodically, but just these two don't work. Help would be much appreciated, thank you!

0
It seems to stop working once a player dies. Hope this makes sense. KingCamembert 57 — 7y
0
Update: I tried fixing it using another anonymous script. Didn't seem to work. KingCamembert 57 — 7y

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You disable it for 10.1 secconds and then enable it for one seccond. That's probably the issue.

You don't even have to disable it An event can fire infinite ammounts of time.

0
I don't think that is the issue. I've tried that, but the first time runs smoothly, and perfectly. I even checked the Lava brick for the second and third time, it just doesn't disable. Any reasons why this would occur? KingCamembert 57 — 7y
0
Run the if statement in the Lava script with a check for a humanoid, aka: if part.Parent:FindFirstChild("Humanoid") then RubenKan 3615 — 7y
0
Still seems to have issues. Thanks for your thoughts, though. KingCamembert 57 — 7y
Ad

Answer this question