Part not cloned when triggered by proximity

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? clone part locally when triggered by proximity and then move the cloned part to character torso

  2. What is the issue? Part doesn’t even clone

  3. What solutions have you tried so far? tried everything

Here’s my script, It is localscript.

local plr = game:GetService("Players").LocalPlayer --get the localplayer
local char = plr.Character or plr.CharacterAdded:Wait()
local proximity = script.Parent.ProximityPrompt
local ProximityPromptService = game:GetService("ProximityPromptService")
local part = workspace.FolderNameHere.PartNameHere

proximity.Triggered:Connect(function()
   part:Clone()
	part.CFrame = char.PrimaryPart.CFrame --ONLY THE CLONED PART SHALL MOVE
end)

You must place the clone in a variable to use it.

local plr = game:GetService("Players").LocalPlayer --get the localplayer
local char = plr.Character or plr.CharacterAdded:Wait()
local proximity = script.Parent.ProximityPrompt
local ProximityPromptService = game:GetService("ProximityPromptService")
local part = workspace.FolderNameHere.PartNameHere

proximity.Triggered:Connect(function()
	local Clone = part:Clone()
	Clone.CFrame = char.PrimaryPart.CFrame
	Clone.Parent = workspace.FolderNameHere
end)

It still didnt work for some reason.
No errors in output or anything

Place print to see where it stops

print("Start")
local plr = game:GetService("Players").LocalPlayer --get the localplayer
local char = plr.Character or plr.CharacterAdded:Wait()
local proximity = script.Parent.ProximityPrompt
local ProximityPromptService = game:GetService("ProximityPromptService")
local part = workspace.FolderNameHere.PartNameHere
print("Assets")

proximity.Triggered:Connect(function()
	print("Clone")
	local Clone = part:Clone()
	Clone.CFrame = char.PrimaryPart.CFrame
	Clone.Parent = workspace.FolderNameHere
end)
print("Ready")

if nothing prints, check the location of the script, localscript only work as a child of the player, its character and some services.

image
Nothing printed here is the localscript location.

The localscript don’t work in workspace, move it to another place like StarterPlayerScripts.

It works now! Thank you! last thing how do i weld the part to the character torso?

You could weld it with WeldConstraint, with a Weld or you can convert it in an accessory.

PS: if my answer above solved your first problem, mark it as a solution.

1 Like