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

How do I fix children of serverstorage disappearing?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

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.

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 ack_superbear 35 — 4y
0
Are you using a ServerScript? youtubemasterWOW 2741 — 4y
0
No, a local script. I put the local script in workspace. ack_superbear 35 — 4y
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) ack_superbear 35 — 4y
View all comments (4 more)
0
LocalScripts aren't useable in Workspace. Use them in StarterPlayerScripts, StarterCharacterScripts, StarterGui, ReplicatedFirst, and the newly upcoming ReplicatedScriptService. youtubemasterWOW 2741 — 4y
0
Okay, I'll try that. ack_superbear 35 — 4y
0
Thanks, it helped! ack_superbear 35 — 4y
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. youtubemasterWOW 2741 — 4y
Ad

Answer this question