- What do you want to achieve?
A Way to delete a player clone, that they created using /clone.
Alternative : delete a player clone using click detector, or when a player resets.
- What is the issue?
ClickDetector is not working, and the clone is not deleting.
- What solutions have you tried so far?
The solutions I’ve tried with this is >
- Creating A Click Detector manually in the local function, and making a function that checks if they click detector gets clicked. If so it deletes the clone.
ClickDetector = Instance.new("ClickDetector", clone)
- Creating A Click Detector and a script with it. Cloning it in the function, and setting the parent to the clone.
The problems im having is that for 1 it basically allows the player to delete the first clone and only that clone. Im guessing because the local function gets called one time everytime you do /clone.
Im trying to figure out how to delete a “model” I guess you could say by a click detector. Also had no idea how to delete the clones if a player resets? How could I achieve any of these?
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local container = workspace
local clone
local ClickDetector = script.ClickDetector:Clone()
local createClone = function(character)
local humanoid = character:FindFirstChild("Humanoid")
local description = humanoid:GetAppliedDescription()
if humanoid then
--Setup clone
character.Archivable = true
clone = character:Clone()
local cloneHumanoid = clone.Humanoid
clone.Name = " "
local specialChar = false
if clone:FindFirstChild("Chest") then
specialChar = true
end
for a,b in pairs(clone:GetDescendants()) do
if b:IsA("Humanoid") then
b.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
elseif b:IsA("BillboardGui") then
b:Destroy()
elseif b:IsA("Weld") and b.Part1 ~= nil then
b.Part0 = b.Parent
if clone:FindFirstChild(b.Part1.Name) then
b.Part1 = clone[b.Part1.Name]
elseif not specialChar then
b:Destroy()
end
end
end
clone.Parent = workspace
cloneHumanoid:ApplyDescription(description)
ClickDetector.Parent = clone
--Animations
local animator = humanoid:FindFirstChild("Animator")
local animator2 = cloneHumanoid:FindFirstChild("Animator")
if animator and animator2 then
for _, v in pairs(animator:GetPlayingAnimationTracks()) do
local track = animator2:LoadAnimation(v.Animation)
track.Priority = Enum.AnimationPriority.Action
track:Play()
track.TimePosition = v.TimePosition
track:AdjustSpeed(v.Speed)
end
end
end
end
local clone = function(plr)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp then
local clone = createClone(character)
local humanoid = clone:FindFirstChild("Humanoid")
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Subject
humanoid.HealthDisplayDistance = 25
humanoid.NameDisplayDistance = 25
humanoid.DisplayName = " "
local cloneHrp = clone:FindFirstChild("HumanoidRootPart")
cloneHrp.CFrame = hrp.CFrame * CFrame.new(0, 5, 0)
clone.Parent = container
clone.Name = " "
end
end
game.ReplicatedStorage.EVENTS.CloneEvent.OnClientEvent:Connect(function(rigType)
clone(rigType)
end)
Note : this topic was part of my clone command. ( people can clone any model )