Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years 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()

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years 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()

Your Script

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 User#30241 0 — 5y
0
Correct, hence why I suggest moving it to ServerStorage. Just2Terrify 566 — 5y
0
Which I explained how to change the script to fix that. Just2Terrify 566 — 5y
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 2009 — 5y
0
I stated that.. Just2Terrify 566 — 5y
Ad
Log in to vote
1
Answered by
Nep_Ryker 131
5 years ago
Edited 5 years 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.

Edit: Didn't realise there was already an answer :P

Log in to vote
0
Answered by 5 years ago
Edited 5 years 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. Just2Terrify 566 — 5y
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 847 — 5y
0
Yes but having it as Game.Lighting.PARTNAME.Parent = Game.Workspace doesn't work. I tried it. Just2Terrify 566 — 5y

Answer this question