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

How do I make this script trigger an event that endlessly makes more parts?

Hello, I'm very new to scripting as I've just started learning it yesterday. I'm currently learning functions and events right now. I need help getting this script working properly in the way I want it to.

game.Workspace.TouchPart.Touched:Connect(function(hit)
	while do true
			Instance.new("Part", game.Workspace)
		wait (1)
	end
end)

What this script is supposed to do, is when your character walks on/touches a specific pre-existing part already placed in Workspace, objects would continuously be created at the center of the Baseplate, and you can no longer stop it. That's a basically the whole gist of the script I'm attempting to make.

Any help is useful.

1 answer

You can use a boolean value to help you with this.

Also it seems that you made a typo with "while true do".

local Touched = false

game.Workspace.TouchPart.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		Touched = true
	end
end)

while Touched == true do
	local InstancedPart = Instance.new("Part", game.Workspace)
	wait(1)
end

2 comments

0

Ooohhhhh, whoops, didn't notice that typo. Thanks for helping, it works now.

0

If this answered your question be sure to accept it :)

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