Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i script a button to give a player a weapon?

Asked by 9 years ago

how do i script a button to give a player a weapon? i started with this,

function.onClicked ()

give.Player.Item:35702550 onClicked

end

im very new to scripting (i started 3 hours ago) Please help

1 answer

Log in to vote
0
Answered by 9 years ago

Put a ClickDetector into the part you want to be clicked. put the weapon you want to give into the ServerStorage

Part = script.Parent -- defines the part

Part.ClickDetector.MouseClick:connect(function(Clicker) -- start event when part is clicked
    local HasWeapon = Clicker.Backpack:FindFirstChild('WeaponName') -- looks for already existing weapon
    if not HasWeapon then -- prevents from getting more than one
    local Clone = game.ServerStorage.WeaponName:Clone() -- duplicates the weapon
    Clone.Parent = Clicker.Backpack -- puts weapon into player's backpack
    end
end)
Ad

Answer this question