Server Script doesn't work when trying to parent a tool to replicated storage

Just realized you meant to parent it to ReplicatedStorage (I would still recommend using ServerStorage). But still no problem.

Make sure to put a RemoteEvent in ReplicatedStorage. you can name it if you want but you need to match the new name with the scripts too

ServerScriptService script



remoteEvent.OnServerEvent:Connect(function(player)
    local backpack = player:FindFirstChild("Backpack")
    if backpack then
        local AK = backpack:FindFirstChild("AK101")
        if AK then
            AK.Parent = game.ServerStorage
        end
    end
end)

Local Script

local remoteEvent = game.ReplicatedStorage.RemoteEvent

script.Parent.MouseButton1Click:Connect(function()
    remoteEvent:FireServer() -- Fire the remote event to the server
end)

There should be this line on the beginning of the ServerScriptService script sorry

local remoteEvent = game.ReplicatedStorage.RemoteEvent

i already corrected that. but thanks for telling

1 Like

i keep getting that a weapon isnt a valid member of serverstorage so ill use replicatedstorage for now.

sadly the thingy doesn’t work. no error’s in the output or something. it just doesn’t get parented to ServerStorage or replicatedstorage (i forgot)

If your problem still doesn’t get solved though I’ll try to replicate it later once I’m back on my PC. It’s kind of hard trying to make scripts if I can’t test it directly

Are you firing the remote event with the tool equipped? If yes, you should know that every tool equipped by the player is placed at his character in workspace, not in Backpack, so:

local AK = backpack:FindFirstChild("AK101")
if AK then -- false if the tool is equipped, so the condition is skipped.
   AK.Parent = game.ServerStorage
end

Maybe you could do a check for searching the tool in player’s character too?

1 Like

IT WORKS TYSMMMMMMM (also thank you to other people who tried to help me)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.