This script is for a brick that clones the avatar who steps on it, to avoid crashes I used debounce and a 60 second wait, but the script will only work once and won't reset.
Anyone know what's causing the problem?
local debounce = false game.Workspace.ClonedPart.Touched:Connect(function(hit) if not debounce then debounce = true script.Parent.BrickColor = BrickColor.new('Really red') local avatar = hit.Parent avatar.Archivable = true local clonedPerson = avatar:Clone() clonedPerson.Name = ('SellBot') clonedPerson.Parent = game.Workspace clonedPerson.Position = Vector3.new(15.23, 5.5, 207.43) debounce = false wait(60) debounce = true script.Parent.BrickColor = BrickColor.new('Medium stone grey') end end)
At the very end of the script, you set debounce=true
, which will make not debounce
false, preventing execution of your code on a touched event.
However, that is not the main issue.
There is an error on line 13, when you try to set clonedPerson.Position
. Presumably, the avatar is the character model, and models do not have a position value. If you want to move the character to a location, you must set Character.HumanoidRootPart.Position
.
This error stops execution of the code before it reaches debounce=false
, which means that the debounce will prevent the cloning from happening again.