Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- All positions of floors where the elevator should arrive at.
- Floor 1 elevator position: 34.7, 0.3, 34.1
- Floor 2 elevator position: 34.7, 14.6, 34.1
- Floor 3 elevator position: 34.7, 30.9, 34.1
- ]]--
- local TweenService = game:GetService("TweenService")
- local elevatorPart = game.Workspace.Elevator
- local informationForTween = TweenInfo.new(
- 7,
- Enum.EasingStyle.Quad,
- Enum.EasingDirection.InOut,
- 0,
- false,
- 0.2
- )
- local propertiesForFloor2_Destination = {CFrame = CFrame.new(7, 14.6, 34.1)}
- local propertiesForFloor3_Destination = {CFrame = CFrame.new(34.7, 30.9, 34.1)}
- local propertiesForFloor1_Destination = {CFrame = CFrame.new(34.7, 0.3, 34.1)}
- local createTweenToFlr2 = TweenService:Create(elevatorPart, informationForTween, propertiesForFloor2_Destination)
- local createTweenToFlr3 = TweenService:Create(elevatorPart, informationForTween, propertiesForFloor3_Destination)
- local createTweenToFlr1 = TweenService:Create(elevatorPart, informationForTween, propertiesForFloor1_Destination)
- game.ReplicatedStorage.Floor1Event.OnServerEvent:Connect(function(player, elevator)
- elevatorPart.Anchored = false
- print("Unanchoring part")
- if not elevatorPart.CFrame == CFrame.new(34.7, 0.3, 34.1) then
- createTweenToFlr1:Play()
- if elevatorPart.CFrame == CFrame.new(34.7, 0.3, 34.1) then
- elevatorPart.Anchored = true
- print("Anchoring Part")
- end
- end
- end)
- game.ReplicatedStorage.Floor2Event.OnServerEvent:Connect(function(player, elevator)
- elevatorPart.Anchored = false
- if not elevatorPart.CFrame == CFrame.new(7, 14.6, 34.1) then
- createTweenToFlr2:Play()
- if elevatorPart.CFrame == CFrame.new(7, 14.6, 34.1) then
- elevatorPart.Anchored = true
- end
- end
- end)
- game.ReplicatedStorage.Floor3Event.OnServerEvent:Connect(function(player, elevator)
- elevatorPart.Anchored = false
- if not elevatorPart.CFrame == CFrame.new(34.7, 30.9, 34.1) then
- createTweenToFlr3:Play()
- if elevatorPart.CFrame == CFrame.new(34.7, 30.9, 34.1) then
- elevatorPart.Anchored = true
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment