I am making a script that spawns a part into workspace once and then disappears after a certain amount of time. I made this as a test to determine to do so but no matter what I put in, it never works. Why?
wait(5) Game.Lighting.PARTNAME = Game.workspace wait(15) workspace.PARTNAME:Destroy()
So if you're trying to copy and move a part or model to Workspace, this is what you want to do. Also a couple tips in here as well. You have the right idea.
What I would recommend working on.
Work on having variables to = what you want. The main reason your script wasn't working is because you had game as Game. Game with a capital G is deprecated. I forgot, thank you @CeramicTile for informing me of that. It has to be lowercase entirely. If you use variables, you'll only have to type that variable to reference a brick or model.
What I did...
I added variables. I would also advise using ServerStorage as a storage space as hackers/exploiters can't access that server but be aware that they can access stuff in Workspace. It also helps make it organized. All you'd have to do is move the part to ServerStorage and change the Lighting to ServerStorage.
--Made by MillerrIAm ----------------Variables------------- Brick = game.Lighting.PARTNAME --The brick you're going to spawn. ---------------Main Script-------------- wait(5) Brick:Clone().Parent = workspace wait(15) workspace.PARTNAME:Destroy()
wait(5) game.Lighting.PARTNAME.Parent = game.Workspace wait(15) workspace.PARTNAME:Destroy()
In Line 2 you forgot to put .Parent..It should be like this:
game.Lighting.PARTNAME.Parent = game.Workspace
Also Lighting is not a good place to store things in. Use ServerStorage instead.
And when saying
game it's best to make the "g" lowercase.
Edit: Didn't realise there was already an answer :P
Change line 2 to
Game.Lighting.PARTNAME.Parent = Game.Workspace
Added the .Parent because in order to move it from one area to another like in this case, you have to change the ancestry of the part.