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

Making a border game and I tried to make a click-to-pick. Why won't it work?

Asked by 3 years ago

So I'm making a border game and I'm currently making it so clicking a passport or permit causes it to go in your inventory. I started off with the permit and it oddly won't work, the permit is a model so I don't get confused or something stupid and it's three parts. If it's the script then please help me fix that.

Script:

local Permit = script.Parent local click = Permit.ClickDetector

local function pickup(player) local newTool = Instance.new('Tool') newTool.Name = 'Permit' local handle = part:Clone() handle.Name = 'Handle' handle.Parent = newTool handle.Script:Desroy() newTool.Parent = game.Workspace:FindFirstChild(player.Name) end

click.Mouseclick:Connect(pickup())

0
Study the fundamentals. You clearly lack basic scripting knowledge and it shows. Dehydrocapsaicin 483 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

You should connect the function by calling it, you did :Connect(pickup())

Just do:

click.Mouseclick:Connect(pickup)
0
Sadly, that didn't make a difference. :( LittleDonkey174 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Here's how I would do it...

local Permit = script.Parent
local click = Permit.ClickDetector

local part = workspace.Part --make a part that you can clone

click.Mouseclick:Connect(function(player)
    local newTool = Instance.new('Tool')
    newTool.Name = 'Permit'
    local handle = part:Clone()
    handle.Name = 'Handle'
    handle.Parent = newTool
    handle.Script:Desroy()
    newTool.Parent = game.Workspace:FindFirstChild(player.Backpack)
end)

Why don't you just pre-make the tool tho if I may ask?

0
When you say pre-make, do you mean "make it yourself"? LittleDonkey174 0 — 3y

Answer this question