Script Help: Script isn't putting my tools into my inventory

Hey!

I’m attempting to script something where the tools that are within the ServerStorage end up cloning and transferring into my backpack upon joining the game.

The following tools that I’m trying to have cloned from ServerStorage is “KickBaton” & “BanBaton” and I then want them to be put into my inventory.

I’m not quite sure what I’m doing wrong here. I’ve tried correcting the errors that are appearing within the error console, that doesn’t appear to be working.

I would love some advice and help with this, that would be much appreciated!

Here are the necessary picture:

Try this instead:

local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
   local MyUserId = 000000 -- Enter your UserId here

   if Player.UserId == MyUserId then
       local Backpack = Player.Backpack

       local BanBaton = ServerStorage.BanBaton:Clone()
       local KickBaton = ServerStorage.KickBaton:Clone()

       BanBaton.Parent = Backpack
       KickBaton.Parent = Backpack
   else
       print("Player does not match the 'MyUserId'")
   end
end)

Interesting…

That also unfortunately didn’t work. I am met with these error(s) instead:

I don’t really want to touch a block or anything as such to receive the tools. I’m just wanting the tools to appear within my inventory upon joining. I’ve spend about an hour trying to figure out the issue prior to creating a post. Not sure what the underlying cause is.

The script I have provided above should work perfectly.

That must be another script interfering with this one since it says Touched is not a valid member of Backpack but I did not use any Touched events in the script I have provided sorry.

Hm, yeah. I noticed upon reading the script.

I’ll attempt to find the underlying script, I might have forgotten to delete a script when coding this.

I’ll keep you updated anyway!

If you need help finding the script causing the error, it is located in the BanBaton and the script is called ‘Giver Script’ from the error message sent in your previous reply.

Yep. I removed that.

Upon further review, I’m no longer getting any error messages which are good. Although the script isn’t executing I believe as the tools aren’t appearing within my inventory upon joining.

The script is in the ServerScriptService which it’s suppose to be, and I don’t think that there’s another script interfering with this process.

I’m not quite sure what the underlying cause could possibly be. I’m just overall confused on what to do next as I’ve never had anything like this happen to me before within my 4 years on scripting.

This is another method that should work:

local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
    local Backpack = Player.Backpack

    local BanBaton = ServerStorage.BanBaton:Clone()
    local KickBaton = ServerStorage.KickBaton:Clone()

    BanBaton.Parent = Backpack
    KickBaton.Parent = Backpack
end)

I’ve already tried that method, that still doesn’t work…

Add a CharacterAdded inside the PlayerAdded and do you code in there.

1 Like

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