Hi, I wanted to make a system that when the light pole is touched, the light pole drops and after 5 seconds it returns to its original position. Is that possible?
Current script:
script.Parent.Touched:Connect(function()
local unanchor = script.Parent.Parent:GetChildren()
for _,v in pairs(unanchor) do
local pos = v.Position
wait(.5)
v.Anchored = false
wait(5)
v.Anchored = true
v.Position = pos
end
end)
1 Like
I suggest you use CFrame instead of Position, since it also includes rotational data. And also you should add a debounce + use coroutines to make sure the script won’t do weird stuff.
local db = true
script.Parent.Touched:Connect(function()
if db then
db = false
for _,v in ipairs(script.Parent.Parent:GetChildren()) do
local cf = v.CFrame
coroutine.wrap(function()
wait(0.5)
v.Anchored = false
wait(5)
v.Anchored = true
v.CFrame = cf
db = true
end)()
end
end
end)