Straight to the point
im working on a game, and i need help with a specific part.
i want to give a player a random ability, like superspeed pr superjump, or an item (one that i made, for example a gun or a sword) when they press a button (shift in my situation). I already figured out how to give a person abilities but i dont understand how to give a player an item.
for example i use a = math.random(1,3) and if a == 1 then ability a or ability b so when it gets 3 i want them to get an item in their inventory. but i dont know how.i dont know the code that takes a tool from the explorer (or anywhere else) and place it into players backpack. i couldnt really find anything on youtube nor google.
Hope yall can help!
ALSO! im kinda new to programing in roblox so if you will use some scripting to explain, please explain how it works to me. i know its kinda a lot to ask for, but i want to not only find a soulution but to understand it and grow!
ThanQ!
in short
if i do: a = math.random(1, 3)
how do i add an item (for example a gun) to players backpack when a == 3
Put the script inside the part
Script.Parent.clickdectector.activated:Connect:function() —function happens when player clicks part
Local num = math.random(1, 3)—rolls d3
If num == 3 then —if d3 rolled 3 then give item
—give player the item
End
End
but i dont want any item to be on the baseplate for me to click, i want to get an item when i press left shift.
im using:
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
local a = math.random(1, 3)
If a == 1 then
--blah blah blah -ect
end)
so when it will give a == 3 i to take a random item (i could use a table for that) and store it into players backpack. so what i need to know is the code that takes an item from the table or somewhere from explorer and put it into players backpack. Not the code that lets me click on a part, clone it, and take it into my backpack