Hey, just started scripting today and I was just playing around with code when I got this idea but I don't know how I would do it. So the idea is to make the parts spawn one at a time while the user is touching another part and if they stop touching the part then the parts that spawned all get removed. I got the second part of my idea done, just need help with the first one. Here's my code so far:
function onTouched(player)
local humanoid = player.parent:FindFirstChild("Humanoid")
if (humanoid ~= nil)
then
local test = Instance.new("Part")
test.Parent = game.Workspace
test.Position = Vector3.new(0,0,0)
test.Size = Vector3.new(5,5,5)
wait(5)
end
end
function onTouchedEnded()
local yurr = game.Workspace:FindFirstChild("Part")
yurr:Destroy()
print("ez clap")
end
script.Parent.Touched:Connect(onTouched)
script.Parent.TouchEnded:Connect(onTouchedEnded)

5 comments
I mean I meant that the parts should spawn one at a time but you simplified the code so thanks anyway :)
No problem! Happy to help!
I edited the script. Is something like that what you meant?
No but that's a very cool script to experiment with, thanks! Btw there's an error in line 8 but the script still works.
Okay, that's good to hear!