New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

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

Edited 10 days ago

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


0
Edited 8 days ago

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


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

0
SO you are saying that hackers and exploiters can go through lighting but not serverstorage Popularjon321 23 — 9d
0
Correct, hence why I suggest moving it to ServerStorage. MillerrIAm 299 — 9d
0
Which I explained how to change the script to fix that. MillerrIAm 299 — 9d
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. hiimgoodpack 1879 — 9d
0
I stated that.. MillerrIAm 299 — 8d
1
Xrp200 115
10 days ago
Edited 10 days ago

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.

0
Edited 10 days ago

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.

0
You missed the main error he had, game can not be capitalized. MillerrIAm 299 — 9d
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. CeramicTile 538 — 9d
0
Yes but having it as Game.Lighting.PARTNAME.Parent = Game.Workspace doesn't work. I tried it. MillerrIAm 299 — 9d