Is this possible in this script?

I created a script whereas when the player presses a keybind, it fires an event to the server and 1.3 seconds after it was fired, a loop starts but i only want the loop to happen 4 times then it should end, in this case i want 4 parts to spawn at least 0.5 seconds from each other then when the 4th one spawns the loop ends, how can i do this? this is my script below

Is it not possible to use a

for index = 1, 4 do
end

instead of a while loop

in your case like:

for _ =  1, 4 do
	local main = game:GetService("ReplicatedStorage").PartSpawns.Gift:Clone()
	
	local explodeclone = explodedessc:Clone()

	local new = main:Clone()
	new.Parent = workspace
	explodeclone.Parent = new

	new.Anchored = false
	new.CanCollide = true
	new.Position = player.Character.HumanoidRootPart.CFrame * Vector3.new(0,10,0)
end
2 Likes

i tried the script and got this error, is there something i did wrong?


this is the error

new.CanCollide not new.Cancollide

1 Like

ok i fixed this and the script works now, i didnt realise this typo before so thanks for calling it out :+1:

1 Like