:Clone() not working

im trying to clone a part and put it in workspace. ( the part is located in serverstorage )
At first it didnt work. So i decided to test it out with another script and it worked.

here is the script:

local closeAnim = require(game.Workspace.door.Animator) 
local debounce = false
local g1 = game.Workspace.gen1
local g2 = game.Workspace.gen2
local g3 = game.Workspace.gen3
local reloaded = game.Workspace.reloaded
local broken = game.Workspace.broken
local coolant = game.Workspace.coolantValue
local bullet = game.ServerStorage:WaitForChild('Rocket') --- Part i want to clone

function onClicked(playerWhoClicked)
	script.Parent.Transparency=1
	if g1.Value and g2.Value and g3.Value and reloaded.Value and coolant.Value then
		print("ready to fire")
		local save = bullet:Clone()  --- problematic line
		if broken.Value == false then
			save.Parent = game.Workspace --- problematic line
			local brokenChance = math.random(0,4)
			game.ReplicatedStorage.CameraShake:FireAllClients()
			game.Workspace["Wind Whoosh Sonic Boom Low End Impact 2 (SFX)"]:Play()
			game.Workspace["Big Explosion"]:Play()
			closeAnim.NewTween1:Play()
			reloaded.Value = false
			if brokenChance == 2 then
				broken = true
				game.ServerStorage.Fire.Parent = game.Workspace
				game.Workspace.brokenPart.ProximityPrompt.Enabled = true
			end
			
			
			
		else
			script.Parent.ProximityPrompt.ActionText = "Component not on or broken"
			wait(2)
			script.Parent.ProximityPrompt.ActionText = "Fire"
		end
		
		
	end
	wait(.1)
	script.Parent.Transparency=0
end
script.Parent.ProximityPrompt.Triggered:Connect(onClicked)

code for the other script:

local cf = CFrame.new(-21.801, 1.5, 12.961)
local bullet = game.ServerStorage.cart
local debounce = false
script.Parent.ProximityPrompt.Triggered:Connect(function()
	if debounce == false then
		debounce = true
		local save = bullet:Clone()
		save.Parent = game.Workspace
		wait(5)
		debounce = false
	end
	
	
end)

for some reason the script above worked

Are you sure bullet exists? If so, I think you should set the position of save.

i dont understand. do you mean the model?

well there is part in the part which has a particle emmiter in it ( lets just call this part “particle” It worked. The part cloned and got put into workspace.but it was anchored and i didnt want it to be anchored. I unanchored particle and it stopped working from there. Im gonna try grouping everything and see if that works.

Wait, I just realized that you were using the first script (and not the second one), my bad.

Are you using a local script or server script?

Im using a serverscript located in a part.

you sure the g1, g2, g3, reloaded and coolant values are set to true due to this line

yes. everything under is running perfectly fine.

So everything in your code works, except for the bullet cloning right?

1 Like

hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

its just the cloning thats not working

Try this code out:

local closeAnim = require(game.Workspace.door.Animator) 
local debounce = false
local g1 = game.Workspace.gen1
local g2 = game.Workspace.gen2
local g3 = game.Workspace.gen3
local reloaded = game.Workspace.reloaded
local broken = game.Workspace.broken
local coolant = game.Workspace.coolantValue
local bullet = game.ServerStorage:WaitForChild('Rocket') --- Part i want to clone

function onClicked(playerWhoClicked)
	script.Parent.Transparency=1
	
	if g1.Value and g2.Value and g3.Value and reloaded.Value and coolant.Value then
		print("ready to fire")
		if broken.Value == false then
			local save = bullet:Clone()
			save.Parent = workspace
			warn("BULLET SUCCESSFULLY CLONED! PARENT IS: " .. save.Parent:GetFullName())
			
			local brokenChance = math.random(0,4)
			
			game.ReplicatedStorage.CameraShake:FireAllClients()
			game.Workspace["Wind Whoosh Sonic Boom Low End Impact 2 (SFX)"]:Play()
			game.Workspace["Big Explosion"]:Play()
			
			closeAnim.NewTween1:Play()
			reloaded.Value = false
			
			if brokenChance == 2 then
				broken = true
				game.ServerStorage.Fire.Parent = game.Workspace
				game.Workspace.brokenPart.ProximityPrompt.Enabled = true
			end
		else
			script.Parent.ProximityPrompt.ActionText = "Component not on or broken"
			task.wait(2)
			script.Parent.ProximityPrompt.ActionText = "Fire"
		end
	end
	task.wait(.1)
	script.Parent.Transparency = 0
end
script.Parent.ProximityPrompt.Triggered:Connect(onClicked)

No. I generate a random number. If the number is 2 i set broken to true.

isn’t it supposed to be “broken.Value”

oh lol i just realized that, but i dont think it has anything to do with the cloning

huh thats weird it printed but didnt show up in workspace
Output: BULLET SUCCESSFULLY CLONED! PARENT IS: Workspace

heres the other script in action if you wanna see.

aight it’s unfortunate that no one has replied or provided the solution in around 19 days yet but have you tried setting the cframe of the rocket just incase it’s actually far away from the common boundaries of supposed spawn?

yeah that was the problem. I was going to post the solution then I forgot. I’ll just mark your comment as the solution.