The purpose of the GUI is to allow the player to select a weapon they want and they spawn with that weapon, but I can't get it to work right.
The weapons are in the game's lighting.
How do I tweak it so the GUI gives the player their weapon whenever they spawn?
local function equip_tools(player) local weps = game.Lighting["Weapons"] local inventory = player:findFirstChild("wep_storage") if inventory then local purchased_wep = weps[inventory.purchased.Value] local gp_wep = weps:findFirstChild(inventory.game_pass.Value) or nil if gp_wep ~= nil then gp_wep:Clone().Parent = player.Backpack end purchased_wep:Clone().Parent = player.Backpack else if map["Tools"]:findFirstChild("LinkedSword") then map["Tools"]["LinkedSword"]:Clone().Parent = player.Backpack else map["Tools"]["Sword"]:Clone().Parent = player.Backpack end end end
local player = game.Players.LocalPlayer --give tools function repeat wait() until player.Character --Just to make sure it doesn't glitch equip_tools() --Since player was already defined there is no need to insert it as a parameter player.CharacterAdded:connect(equip_tools)
Sorry if this doesn't work, I'm tired and a tad rusty recently. Try it out and give output if it doesn't work out!
Also if you can't use it as a local script you could do
game.Players.PlayerAdded:connect(function(player) --give tools function repeat wait() until player.Character equip_tools() player.CharacterAdded:connect(equip_tools) end)
Try either of these out
Sidenote: The first one has to be a local script inside the StarterGui or StarterPack