Tool won't be added in backpack when player joins

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make it so that after the character does an animation(with tool 1 which should spawn in with you) infront of a part. The part gives tool number 2 to the player.

  1. What is the issue? Include screenshots / videos if possible!

For the animation, I’ll be using tool number 1, and I want to script it so that when the player spawns in, the tool which is stored in the server, is cloned and given to the player.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve changed where I was stocking the tool number 1, it was first in a folder, and I then put it in the server storage.

local Players = game:GetService("Players") -- pleyers


Players.PlayerAdded:Connect(function(player) -- player is the one who joined	
	print("hi")
	game.ServerStorage.Tools["BowDown"]:Clone().Parent = player:WaitForChild("BackPack")
	game.ServerStorage.Tools["BowDown"]:Clone().Parent = player:WaitForChild("StarterPack")

end)

‘hi’ cannot be seen in the output.
So maybe the script is fine but roblox studio is being weird?

Here’s where the script + tool are stocked

image

player:WaitForChild("BackPack") -- you meant 'Backpack'
player:WaitForChild("StarterPack") -- StarterPack are for tools the player will start with

i’m assuming it’s yielding

--local Players = game:GetService("Players") -- pleyers


Players.PlayerAdded:Connect(function(player) -- player is the one who joined	
	game.ServerStorage.Tools["BowDown"]:Clone().Parent = player:WaitForChild("Backpack")
	

end)

It’s still not workig :confused:

you could also just put the bowdown in starterpack

true, but scripting it gives experience, which I definitly want.
And know that there’s the error, it needs to be solved

does it work the first time and stop working when they respawn?

doesn’t work when they spawn and neither when they respawn

also, if that script is inside the tool, you might wanna change that, put 1 script in serverscriptservice that handles that instead, because first, script inside serverstorage dont work (i think) and second is it will keep duplicating more and more for each player with that tool inside their backpack

is that script or local script??

imagine theres 10 players with that tool that have “givetool” script, the 11th player joining will give each player 11 duplicate tools

i understand that you want experience but you should learn when to do something easier

-- ServerScript inside of ServerScriptService
local SS = game:GetService("ServerStorage")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
   -- wait for tools instead
    local BowDown = SS :WaitForChild("Tools")["BowDown"]:Clone()
   -- no need to wait for the backpack
    BowDown.Parent = player.Backpack
end)

lol ok, but after I moved it in serverscript still doesn’t work

It’s a normal script.

(I need to put more characters don’t mind this)

i opened studio to make quick test, i found the problem, ur placing the tool too early the character havent loaded yet, try this
givetool
this also keeps giving the player the tool when their character respawned

2 Likes

Thanks ! I learned alot from all the help I got :slight_smile:

that script is also inside serverscriptservice , and not inside the tool, because if its inside the tool, the more players in the server, the more tools the next player joining will receive

1 Like

hey, is there some kind of post talking about why tools duplicate when their local script is inside said tool?

if its local script inside tool it wont be the problem of duplication but if u put a normal script inside the tool that is in charge of cloning a tool and giving it to player, the more tool of the same kind existing in game, the more events will be fired causing multiple tools to be given to the next player, i suggest just putting 1 normal script in serverscriptservice in charge of giving tools

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