Part copies just once

Hello.

I’ve made a vending machine that drops bloxy cola everytime you use the ProximityPrompt.
But the thing is, that the bloxy cola spawns just once and there is no matter how many times you press the ProximityPrompt.

Here is a video:
Problem (2).wmv (2.1 MB)

As you can see in the video the bloxy cola can spawn just once.

This is the SIMPLE script

local clone = game.ReplicatedStorage.Stuff.BloxySodaSpawn:Clone()

function Ordered()
script.Parent.Buy_1:Play()

clone.Parent = game.Workspace["Bloxy Soda Clones"] --Copies it into Folder Bloxy Soda Clones
clone.Position = Vector3.new(12269.891, 15.873, 39.564)
clone.Orientation = Vector3.new(0, -29.17, 58.14)
end

script.Parent.Attachment.ProximityPrompt.Triggered:Connect(Ordered)

Any help would be appreciated.

because you’re only cloning it once, put the clone inside the function.

1 Like

Like @EnigmaticDevil said, you need to put the clone inside the function, because a new clone need to be created each time you trigger the prompt.

script.Parent.Attachment.ProximityPrompt.Triggered:Connect(function()
	local clone = game.ReplicatedStorage.Stuff.BloxySodaSpawn:Clone()
	script.Parent.Buy_1:Play()
	clone.Parent = game.Workspace["Bloxy Soda Clones"]
	clone.Position = Vector3.new(12269.891, 15.873, 39.564)
	clone.Orientation = Vector3.new(0, -29.17, 58.14)
end)