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

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

Asked by
60DV 0
5 years ago

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.

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

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

Log in to vote
1
Answered by
SnowieDev 171
5 years ago
Edited 5 years ago

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

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

01local Touched = false
02 
03game.Workspace.TouchPart.Touched:Connect(function(Hit)
04    if Hit.Parent:FindFirstChild("Humanoid") then
05        Touched = true
06    end
07end)
08 
09while Touched == true do
10    local InstancedPart = Instance.new("Part", game.Workspace)
11    wait(1)
12end
0
Ooohhhhh, whoops, didn't notice that typo. Thanks for helping, it works now. 60DV 0 — 5y
0
If this answered your question be sure to accept it :) Sulu710 142 — 5y
Ad

Answer this question