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
4 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.

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

Log in to vote
1
Answered by
SnowieDev 171
4 years ago
Edited 4 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".

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
0
Ooohhhhh, whoops, didn't notice that typo. Thanks for helping, it works now. 60DV 0 — 4y
0
If this answered your question be sure to accept it :) Sulu710 142 — 4y
Ad

Answer this question