I've been trying to recreate a IOS game in which on different floors the spikes are randomly generated in different locations. I've hardly ever scripted in my life and have been trying to use a couple of free models to make these works, but they don't seem to work and so I've came here for assistance.
This is what I've gotten from a free model and edited a bit, but it doesn't work.
while true do c = game.Workshape.Spike:clone() c.Parent = Workspace c.Position = Vector3.new(math.random(-60,60), 40, math.random(-60,60)) wait(0) end
Thank you for any help you give.
You're missing game.
before Workspace
on line 3
Side note: wait(0)
is basically useless. Just using wait()
without a number will make the script wait for a short time. Use that to avoid overloading stuff.
Another side note: Use a for
loop if you want there to be a certain amount of spikes, like so
for i = 1, 10 lines 2-5 here end
This will make the code inside the loop run 10 times, creating 10 spikes. You can change 10 to whatever number and the code inside the loop will run that many times.