I recently made a script that spawns a part from ServerStorage to workspace and it only works once before it breaks and doesn't work after I try it again. Why doesn't my script work EVERYTIME when it is triggered
function Ontouched(PartTest) wait(3) game.ServerStorage.Laser.Parent = game.Workspace wait(14) workspace.Laser:Destroy() end
You're moving the laser to the workspace and destroying it which removes it for good. You should utilize cloning for stuff line this.
function OnTouched(partTest) wait(3) local laserCopy = game:GetService("ServerStorage").Laser:Clone() --Clones the laser and stores it in a variable for later so you don't accidentally delete the wrong laser laserCopy.Parent = workspace wait(14) laserCopy:Destroy() --Destroy the copy of the laser specifically stored in this variable so it will only ever destroy that specific clone end