Thank you for catching those, fixed my source code.
Without the second ), I still get an error.
Oh, it is because you also had a .CharacterAdded connection, which you forgot to close.
This should fix it
local replicatedStorage = game:GetService ("ReplicatedStorage")
local tools = replicatedStorage:WaitForChild ("Tools")
function giveRandomTool(backpack)
local _tools = tools:GetChildren() -- NOTE: '_tools' is not the same as 'tools'
local randomTool = _tools[math.random(1,#_tools)]:Clone() -- we clone because we don't want the tool to be lost forever after giving it away
randomTool.Parent = backpack
end
-- I believe the problem was there was no connection to carry out the action, so nothing was done in the end
game.Players.PlayerAdded:Connect (function (player)
player.CharacterAdded:Connect (function (character)
local backpack = player:WaitForChild ("Backpack")
giveRandomTool (backpack) -- we insert into backpack everytime character spawns
end)
end)
Do I still need custom backpack if it’s re-enabled after Gui interfereance?
No it’ll be fine. It’ll be waiting there once the backpack GUI comes back.
Hmm…
This still isn’t working.
Any other ideas?
Edit1: Im going to tes this script in a test environment and see if my other scripts are interfering with execution.
With just the script and Stabbers folder, I still got no result.
@njesk12
This is probably my noob mind and skills, but is there anything I needed to change in the script?
You need to change
local tools = replicatedStorage:WaitForChild ("Tools")
To:
local tools = replicatedStorage:WaitForChild("Stabbers")
Since you have your tools in there. If you’re using @ComplexMetatable’s script.
No it’s my bad! I forgot to add the correct the name of the folder in my source code! check my code for edits!
Thank you guys for helping, this works now! Couldn’t have done it without you!