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

can you help me how to make a drop and pick up gun script?

Asked by 5 years ago

i want to make a gun game! i dont now how to make a drop and pick up gun script! I really need your support

0
If its a tool, you should be able to just drop it by pressing backspace. Kullaske 111 — 5y
0
can you help us by posting your scripts? hellmatic 1523 — 5y

2 answers

Log in to vote
0
Answered by
Voxozor 162
5 years ago
Edited 5 years ago

Hello drbanana2go! To pick up a tool: insert a Script in the tool and place this:

local debounce = false

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("HumanoidRootPart") 
if (human ~= nil) and debounce == false then -- When the player touches the part, it will execute the following script.

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 

script.Parent:clone().Parent = player.Backpack --Copy the tool inside the Backpack

wait(2)
debounce = false
end
end


script.Parent.Parent.Touched:connect(onTouch) 

Also to drop a tool: click on backspace in your keyboard.

0
bad answers 101 User#23365 30 — 5y
0
xd hellmatic 1523 — 5y
Ad
Log in to vote
0
Answered by
Vmena 87
5 years ago

There is a property of the tool called CanBeDropped, set that to true and use backspace to drop. Whenever the tool is dropped, you simply touch it to pick it up.

Answer this question