"say i click a text button" I want the script to get the tool assigned to that text button and equip it to the player who clicked the text button.
I don't want the tool to be in the starter GUI.
local player = game.Players.LocalPlayer -- Refer to the Player local tool = game.ReplicatedStorage.Sword -- Refer to the Tool script.Parent.MouseButton1Down:connect(function() -- When it's clicked if player:FindFirstChild("Backpack") then -- Not sure why I added this tool:Clone().Parent = player.Backpack -- Clone the tool to their inventory end -- End the if function end) -- End the MouseButton1Down function
Sorry I can't explain it any better.
Hi! I'll help you out bro! The 1st thing you need to do is insert a "Screen GUI" and second insert a "Frame" and after that, insert a "Text Button" You need to put the weapon in the text button for it to work, not in lighting. Last but not least, insert this script to to screen GUI and you're good to go.
Here's the script:
player = script.Parent.Parent.Parent backpack = player.Backpack function chooseClass(class) for i, v in pairs(backpack:GetChildren()) do v:remove() end for i, v in pairs(class:GetChildren()) do if v:IsA("Tool") then v:clone().Parent = backpack elseif v:IsA("HopperBin") then v:clone().Parent = backpack end end script.Parent.Main.Visible = false script.Parent.Title.Visible = false end function onHumanoidDied(humanoid, player) script.Parent.Main.Visible = true script.Parent.Title.Visible = true end for i, v in pairs(script.Parent.Main:GetChildren()) do v.MouseButton1Up:connect(function () chooseClass(v) end) end
If you're having trouble, you can check the link below to the model.
http://www.roblox.com/Gui-Giver-item?id=318404466
Good luck on your game!