Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plate = script.Parent:WaitForChild("Plate")
- local door = script.Parent:WaitForChild("Door")
- local region = script.Parent:WaitForChild("PlateRegion")
- local ts = game:GetService("TweenService")
- local ti = TweenInfo.new(0.3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
- local plateDownTween = ts:Create(plate, ti, {Position = plate.Position - Vector3.new(0, plate.Size.Y/2, 0)})
- local plateUpTween = ts:Create(plate, ti, {Position = plate.Position})
- local touching = {}
- region.Touched:Connect(function(hit)
- if hit.Name == "HumanoidRootPart" and #touching < 1 then
- table.insert(touching, hit)
- plateDownTween:Play()
- door.Transparency = 1
- door.CanCollide = false
- end
- end)
- region.TouchEnded:Connect(function(hit)
- if hit.Name == "HumanoidRootPart" then
- table.remove(touching, touching[hit])
- end
- if #touching < 1 then
- plateUpTween:Play()
- door.Transparency = 0
- door.CanCollide = true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement