You can write your topic however you want, but you need to answer these questions:
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.
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.
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?
--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)
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
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)
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
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