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

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

Asked by 3 years ago

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)
0
If you're trying to give it to the player who clicks, put it in the players backpack Lenoske 0 — 3y

1 answer

Log in to vote
0
Answered by
Desmondo1 121
3 years ago
Edited 3 years ago

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)
Ad

Answer this question