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

How do I fix children of serverstorage disappearing?

So I'm trying to make it so that when the player presses F, an Asteroid falls from the sky. When I do it with a regular script it works, but with a Local Script it doesn't.~~~~~~~~~~~~~~~~~ local AST = game.ServerStorage.Asteroid local UIS = game:GetService("UserInputService")

AST:Clone()

UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.F then AST:Clone().Parent = workspace end end)


Please help!

1 answer

✓ Accepted answer

Hello there!

ServerStorage cannot be accessed by LocalScripts as it is for ServerScripts only.

Though, there's an easy solution for this; just use ReplicatedStorage.

Please accept this answer if it helped you.

8 comments

0

Well, I don't get any errors, but when I use the clone function, and I press F, nothing happens, I even set the parent as workspace using AST:Clone().Parent = worksapce

0

Are you using a ServerScript?

0

No, a local script. I put the local script in workspace.

0

Here's the script I used: local AST = game.ReplicatedStorage.Part local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.F then AST:Clone().Parent = workspace end end)

0

LocalScripts aren't useable in Workspace. Use them in StarterPlayerScripts, StarterCharacterScripts, StarterGui, ReplicatedFirst, and the newly upcoming ReplicatedScriptService.

0

Okay, I'll try that.

0

Thanks, it helped!

0

No problem. Please accept my answer. There's been a bug where you can't see the accept answer button unless you go into incognito mode, so if the accept answer button doesn't show for you, use incognito mode.

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