I want to put a few objects into ServerStorage after the player clicks the play button.
I used a code, that I was sure would work, but there were no errors, and it just didn’t do anything.
There are no errors, so I don’t know what to look for.
Here is my very beginner code.
local storage = game.ServerStorage
local player = game.StarterPlayer
local gui = game.StarterGui
local mapFolder = game.Workspace.Map --the folder where all the map objects are in
gui.ScreenPlay.PlayBtn.MouseButton1Click:Connect(function(MouseBtnClick) --playbutton clicked
print("PlayClicked")
mapFolder["Misc."].MenuKid.Parent = storage
mapFolder["Misc."].Ball.Parent = storage
mapFolder["Misc."].SmokeParticle.Parent = storage
--putting all the objects i want gone into storage.
end)
I am assuming that this is a LocalScript. That means that all this is processed by the client, which cannot access some server-sided services, such as ServerStorage and ServerScriptService. That is why you cannot move instances inside those services, because the client has no access to them.
If this was a localscript, I would advise you to move your instances to ReplicatedStorage, which is a shared service with the Server, but that players have access to.
If this is a serverscript, I wouldn’t use MouseButton1Click on a server script, so you will probably have to use remoteevents with both a localscript receiving the Mousebutton1click event and firing the remote event and a serverscript to receive that remote event and handle the instances re-parenting.
Hope this helps!
Also why are you trying to store these objects? Why not clone them when they are needed and then when not needed just get rid of them? Either through :Destroy or DebrisService