I've made a brick that when being touched, clones the player's character on command.
The cloning part worked successfully, but it won't stop cloning once it's first clone. I plan to only made one clone.
I used a normal script parented by the part that does the function.
script.Parent.Touched:Connect(function(hit) local db = false local plr = hit.Parent local hum = plr:FindFirstChildWhichIsA('Humanoid') plr.Archivable = true if ( hum ) and not db then db = true print("hi") local clone = plr:Clone() clone.Parent = workspace wait(7) db = false clone:Destroy() end end)
I have used some guidance from the wiki.
That means it will always start off as false
each time the part is touched. You meant to declare it outside the function.
plr
is a misleading identifier, hit.Parent
will never be a player, the most it will be is a player's character.
```lua local Players = game:GetService("Players"); local Workspace = game:GetService("Workspace"); local debounce = false;
script.Parent.Touched:Connect(function(part) if (debounce) then --// return out the function if cant touch return; end
local client = Players:GetPlayerFromCharacter(part.Parent); --// using the humanoid to check if player is unreliable, anything can have a humanoid if (client) then debounce = true; local character = client.Character; character.Archivable = true; character:Clone().Parent = Workspace; wait(7); debounce = false; end
end); ```