i couldnt do it
local part = game.Workspace.door local part2 = game.Workspace.Part local part3 = game.Workspace.Parte local replica = game.Workspace.replic part.touched:Connect(function(hit) if hit.parent:FindFirstChild("Humanoid") then wait(0.1) local imrandom = math.random(1,2) print(imrandom) if imrandom == 1 then local resetSeconds = 1 local isTouched = false if not isTouched then isTouched = true end wait(resetSeconds) isTouched = false local door = Instance.new("Part", workspace) door.Transparency = replica.Transparency door.Material = replica.Material door.Position = part.Position door.Size = replica.Size else for i = 0,1, .01 do wait() part.CFrame = part.CFrame:Lerp(part2.CFrame, i) end end end end)
help
Here's an example of how a debounce is implemented in a code. Remember that debounces are only there to prevent a code from running too many times.
local part = game.Workspace.door local part2 = game.Workspace.Part local part3 = game.Workspace.Parte local replica = game.Workspace.replic local debounce = true part.Touched:Connect(function(hit) if hit.parent:FindFirstChild("Humanoid") and debounce then debounce = false wait(1) -- change to the amount of seconds you want this to elapse local imrandom = math.random(1,2) print(imrandom) if imrandom == 1 then local resetSeconds = 1 local isTouched = false if not isTouched then isTouched = true end wait(resetSeconds) isTouched = false debounce = true local door = Instance.new("Part", workspace) door.Transparency = replica.Transparency door.Material = replica.Material door.Position = part.Position door.Size = replica.Size else for i = 0,1, .01 do wait() part.CFrame = part.CFrame:Lerp(part2.CFrame, i) end end end end)
:touched
should be :Touched
. :touched
is not an event.Sorry for not answering sooner, comment if you have more questions or replies!
Fixed minor errors!