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

Model wont clone multiple times?

So I have a supply drop model that is supposed to change it's position when a button is pressed so it can fall and a player can use it. It gets taken from replicated storage where it can then be clones and set in the sky above the map. When the model falls to the ground and player clicks on it, the whole model gets destroyed and they are given tools. This works fine the first button press but when it's pressed for a second time the model won't appear. Any help? The code to clone it is inside a script which is inside the button.

local MedDrop = game.ReplicatedStorage.FallingMedBox:Clone()

debounce = true

script.Parent.ClickDetector.MouseClick:Connect(function()
	if debounce == true then
		debounce = false
		
		MedDrop.Parent = game.Workspace
		MedDrop:SetPrimaryPartCFrame(CFrame.new(-158, 202.5, 240))
		wait(1)
		debounce = true
	end
end)

1 answer

✓ Accepted answer

That's because you cloned it and you're using that single clone of the model, so what you want is to clone it every time the clickdetector is clicked


debounce = true

script.Parent.ClickDetector.MouseClick:Connect(function()
    if debounce == true then
	local MedDrop = game.ReplicatedStorage.FallingMedBox:Clone()
        debounce = false

        MedDrop.Parent = game.Workspace
        MedDrop:SetPrimaryPartCFrame(CFrame.new(-158, 202.5, 240))
        wait(1)
        debounce = true
    end
end)

1 comment

0

Oh thanks so much! Never even though of putting it all inside of the clickdetector.

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