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

(intermediate) Script Half-way works, but nothing happens at the end. No out put errors?

local h = script.Parent.Humanoid

while true do
	h:MoveTo(workspace.DontClean1.Position)
	wait(5)
	h:MoveTo(workspace.DontClean2.Position)
	wait(5)
end

if h.Health then
	if h.Health == 0 then
		game.Lighting.SuperEvilKeycard:Clone().Parent = game.Players.LocalPlayer.Backpack
		script.Parent:Destroy()
	end
end

The humanoid moves, but when it dies, nothing happens. There isn't any output errors, i dont know what's happening. as always, i would be happy to elaborate

1 comment

0

You could try using the Humanoid.Died event instead

1 answer

As the post above me said, you've got a loop that won't let your script continue. Therefore, you're going to need to force the script to run two things at once. Scary, I know. This is when we can use the Spawn() function, which you can read more about here.

local h = script.Parent.Humanoid

function onDeath()
	if h.Health then
		if h.Health == 0 then
		game.Lighting.SuperEvilKeycard:Clone().Parent = game.Players.LocalPlayer.Backpack
		script.Parent:Destroy()
		end
	end
end

spawn(function(onDeath))

while true do
    h:MoveTo(workspace.DontClean1.Position)
    wait(5)
    h:MoveTo(workspace.DontClean2.Position)
    wait(5)
end

If this helped you out, consider accepting this answer. If not, let me know and I'll be sure to help you out further.

1 comment

0

None of it works

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