Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a tool move to StarterPack when I click a clickdetector?

So I tried to make this vending machine script where if I press on it, it moves a soda can tool into starterpack. Im fairly new to scripting and its not giving me errors in the output.

local soda = script.Parent.Soda
local ClickDetector = script.Parent.ClickDetector


local vendingMachineClick = function()
	soda.Parent = game.StarterPack
end

ClickDetector.MouseClick:Connect(vendingMachineClick)

1 comment

0

If you're trying to give it to the player who clicks, put it in the players backpack

1 answer

✓ Accepted answer

Don't put it in the starter pack, put it in the players backpack. If this is a local script, then do this

local Player = game.Players.LocalPlayer

local ClickDetector = script.Parent.ClickDetector

local  VendingMachineClick = function()
      script.Parent.Soda.Parent = Player.Backpack
end

If it's a server script, well you can type this

script.Parent.ClickDetector.MouseClick:Connect(function(Player)
      script.Parent.Soda.Parent = Player.Backpack
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.