Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can I make a part that spawns into workspace once and then destroys?

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()

3 answers

✓ Accepted answer

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.

My script

--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()

Your Script

wait(5)
game.Lighting.PARTNAME.Parent = game.Workspace
wait(15)
workspace.PARTNAME:Destroy()

5 comments

0

SO you are saying that hackers and exploiters can go through lighting but not serverstorage

0

Correct, hence why I suggest moving it to ServerStorage.

0

Which I explained how to change the script to fix that.

0

Putting it in serverstorage won't make it any more secure as you're already cloning it to workspace meaning that a hacker can already access the part.

0

I stated that..

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.

3 comments

0

You missed the main error he had, game can not be capitalized.

0

Wrong. His main problem was that his part wasn't spawning a part from lightning to workspace, then deleting itself. Game being capitalized is just deprecated and I probably should have mentioned that in the post but it's most certainly not the main problem and it can be used.

0

Yes but having it as Game.Lighting.PARTNAME.Parent = Game.Workspace doesn't work. I tried it.

This discussion is preserved as it was. New answers, comments, and votes are closed.