This code is supposed to have a 20% chance of spawning in a part from server storage and then destroy it 29 seconds later. If it does not spawn the part it is then supposed to wait for 6 seconds before attempting to spawn the part again. I checked to make sure its name in server storage was "Part" and at this point, the only error I am receiving is to close "while true do" with an "end" which would crash my studio. Does anyone know the problem with the script?
while true do Bodys = math.random (1,5) if Bodys == 5 then local model = game.ServerStorage.Part:Clone() model.Parent=game.Workspace wait(29) model:Destroy() else wait(6) end
while wait() do Bodys = math.random (1,5) if Bodys == 5 then local model = game.ServerStorage.Part:Clone() model.Parent=game.Workspace wait(29) model:Destroy() else wait(6) end end
You are missing an "end"; since you have "while true do" and an "if" there should be two "end"s.
Here's your code with a small edit:
while true do Bodys = math.random (1,5) if Bodys ==5 then local model = game.ServerStorage.Part:Clone() model.Parent=game.Workspace wait(29) model:Destroy else wait(6) end end
If you have any questions or problems please contact me. ;)