I was doing some testing because animations won’t work when they come from ReplicatedStorage, and so I’m using a sword because I thought that would work, it didn’t work, so I tried to put it in ServerStorage, it would give in ReplicatedStorage, but not in ServerStorage, can anyone explain?
Code: local tool = game.ServerStorage.ClassicSword local player = game.Players.LocalPlayer
That is simple. You can not get anything in the ServerStorage from a local script. That is because ServerStorage is on the server side, not the client.
The client (I’m assuming it’s being run by one as you’re using LocalPlayer and GUI events) cannot access ServerStorage. ReplicatedStorage can be accessible by both the client and the server, but the client would have to ask the server to clone the sword for them because of filtering. Try sending a remote event! They’re really useful.
First, you’d want to put a RemoteEvent in ReplicatedStorage. It could be in a folder, or just plainly inside of ReplicatedStorage. Now, we get on to the code.
Server:
local event = game.ReplicatedStorage.RemoteEvent -- Path to the RemoteEvent
event.OnClientEvent:Connect(function(plr)
game.ServerStorage.ClassicSword:Clone().Parent = plr.Backpack
end)
Client:
local event = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
event:FireServer()
end)
If you run into any issues using this let me know.