Hello!
I want to make a platform for my obby that moves along several points I have placed along as its route. If the player were the fall off the platform the platform will continue going towards its route as scripted, but a countdown will initiate. If the countdown was to reach 7 seconds, it will reset the platform back to its starting position and wait for the player to get back on it again to reattempt the course, however if the player were to get back on before the count down reached 7 seconds it should reset the countdown back to 0 and the platform will continue along as normal without being reset. If anyone can help me learn more about how to use the AlignPosition object I’d greatly appreciate it as it’s something that has been giving me trouble understanding.
Here is my current script:
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local zone1 = Zone.new(game.Workspace:WaitForChild("PlatformMoverZONE"))
local platform = game.Workspace:WaitForChild("PlatformMover1")
local PlayerStateonPlatform = false
local countdown = 0
local countdownActive = false
local StarterPosition = game.Workspace.PlatformMoverPOS1.Position
local Position1 = game.Workspace.PlatformMoverPOS2.Position
local CountdownMax = 7
local CountdownMin = 0
local delayReached = false
platform.AlignPosition.Position = StarterPosition
zone1.playerEntered:Connect(function(player)
print("player is in zone")
PlayerStateonPlatform = true
countdown = 0
countdownActive = false
for i, position in ipairs({StarterPosition, Position1}) do
platform.AlignPosition.Position = position
task.wait(1 and 3)
if countdown >= 7 then break end
end
end)
zone1.playerExited:Connect(function(player)
print("player is out of zone")
PlayerStateonPlatform = false
countdownActive = true
end)
spawn(function()
while true do
if countdownActive then
countdown = countdown + 1
if countdown >= 7 then
platform.AlignPosition.Position = StarterPosition
countdownActive = false
countdown = 0
end
end
task.wait(1)
end
end)
Thank you!