Hi, I want to make that if you click on button, it gives you a gun.
local gun = game.ReplicatedStorage.pistolpewpew
game.Players.PlayerAdded:Connect(function(player)
local Character = player.Character
local backpack = Character:FindFirstChild("Backpack")
script.Parent.MouseButton1Click:Connect(function()
gun.Parent = backpack
end)
end)
Localscript is in button part. Can someone help me?
local gun = game:WaitForChild("ReplicatedStorage").pistolpewpew
game.Players.PlayerAdded:Connect(function(player)
local Character = player.Character
script.Parent.MouseButton1Click:Connect(function()
gun:Clone().Parent = player.Backpack
end)
end)
Add a script inside ServerScriptService and type this code:
game.Players.PlayerAdded:Connect(function(plr)
"replace this with your button location".MouseButton1Click:Connect(function()
game.ReplicatedStorage.pistolpewpew.Parent = plr.Backpack
end)
end)
I hope this helped!
If it does not work right, feel free to ask for help.
I did this on my phone so it will look Messy.