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

What Script do I use to touch a brick to give me a gear? [closed]

Asked by 5 years ago

I have been trying the old script

01  local debounce = false
02   
03  function getPlayer(humanoid)
04  local players = game.Players:children()
05  for i = 1, #players do
06  if players[i].Character.Humanoid == humanoid then return players[i] end
07  end
08  return nil
09  end
10   
11  function onTouch(part)
12   
13  local human = part.Parent:findFirstChild("Humanoid")
14  if (human ~= nil) and debounce == false then
15   
16  debounce = true
17   
18  local player = getPlayer(human)
19   
20  if (player == nil) then return end
21   
22  script.Parent:clone().Parent = player.Backpack
23   
24  wait(2)
25  debounce = false
26  end
27  end
28   
29   
30  script.Parent.Parent.Touched:connect(onTouch)

This is the one that doesn't work.

So I tried fixing it but it still didn't work. Can you help me?

0
"the old script" This is not free model support. You have not shown any attempt to debug it or explain how it works, and also have provided code with deprecated methods. I have marked this as non-constructive and off-topic as this is not for free model help nor will we make a model for you hiimgoodpack 2009 — 5y

Closed as Not Constructive by hiimgoodpack and royaltoe

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

3 answers

Log in to vote
0
Answered by 5 years ago

Change line 22 to something to point to where you have your gear such as serverstorage...

game:GetService("ServerStorage").YOURGEAR:clone().Parent = player.Backpack

1
Oh so I needed to get service to server storage? NotFrindow 346 — 5y
1
Not really, you can put the gear you want to clone where ever you want it. I typically store stuff in server storage as opposed to workspace so it doesn't get picked up or something kangerujack 20 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

What your going to have to do is detect when the part is touched on the server, then clone a tool to their backpack (or character for instant equip).

local Player = game:GetService('Players')

local Tool = script.Tool -- Put the tool in the script
local Part = workspace.Part -- Define the part here

local Debounce = false

Part.Touched:Connect(function(Obj)
    if Debounce then return end
    Debounce = true
    local Player = Players:GetPlayerFromCharacter(Obj.Parent)
    if Player then
        Tool:Clone().Parent = Player.Backpack
        wait(1)
        Debounce = false
    end
end)
Log in to vote
0
Answered by 5 years ago

use the toolbox