Clone not working

Im trying to make a C4 spawn wherever I click, and its been working fine for the most part except when I try to actually spawn the C4.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnC4Signal = ReplicatedStorage.RemoteEvents.RemoteEvent

local C4clone = ReplicatedStorage.C4:Clone()

local function PlaceC4(Player, Door, HitPoint)
	print (HitPoint)
	print (Door.Name)
	C4clone.Parent = Door
	C4clone.Position = Vector3.new(HitPoint)
	print (C4clone.Position)
end

SpawnC4Signal.OnServerEvent:Connect(PlaceC4)

Im getting 0 errors but the C4 wont become a child to the Door and the Position wont change either, the HitPoint and Door variables are returning the correct values but when i print the C4clone.Position it says 0,0,0 indicating it didn’t move at all (The HitPoint variable is not 0,0,0 when it prints) I would appreciate any help.

I might be wrong, but I think it’s because you’re creating the clone outside of the function. Try instead placing the cloning part inside the function at the top.

Move the local C4clone = ReplicatedStorage.C4:Clone() part inside the function and see if it works.
like so:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnC4Signal = ReplicatedStorage.RemoteEvents.RemoteEvent

local function PlaceC4(Player, Door, HitPoint)   
    local C4clone = ReplicatedStorage.C4:Clone()
	print (HitPoint)
	print (Door.Name)
	C4clone.Parent = Door
	C4clone.Position = Vector3.new(HitPoint)
	print (C4clone.Position)
end

SpawnC4Signal.OnServerEvent:Connect(PlaceC4)

The reason it wasn’t working is because it just created a clone just once when the script ran instead of creating one everytime the function is run

1 Like

Unfortunately, the same thing is happening, no errors but the part isn’t appearing and the position still stays 0,0,0. When i look into explorer I notice that the part doesn’t even show up after getting cloned. If it helps I am trying to clone a MeshPart into a regular part (So I’m not cloning a model into a model or a part into a model) but I’m not sure if that is important.

Wait, i noticed what happened, idk how I didn’t notice this but, when trying to give the position to my part, I was supposed to specify the X Y Z values

C4clone.Position = Vector3.new(HitPoint.X, HitPoint.Y, HitPoint.Z)

So like that