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

How would I fix this looped killing event?

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!

2 comments

0

It seems to stop working once a player dies. Hope this makes sense.

0

Update: I tried fixing it using another anonymous script. Didn't seem to work.

1 answer

✓ Accepted answer

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.

3 comments

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?

0

Run the if statement in the Lava script with a check for a humanoid, aka: if part.Parent:FindFirstChild("Humanoid") then

0

Still seems to have issues. Thanks for your thoughts, though.

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