Hello,
This script only teleports or gives players walkspeed to one player when it says to do it to all players.
Any help?
Full Code:
local mapCount = 4
while true do
wait(10)
local TweenService = game:GetService("TweenService")
local part = game.Workspace.ElevatorShaft.DoorPart1
local part2 = game.Workspace.ElevatorShaft.DoorPart2
--Closed
local goal1 = {}
goal1.Position = Vector3.new(-4.451, 6.5, -206)
local goal2 = {}
goal2.Position = Vector3.new(-4.451, 6.5, -200)
-- Open
local goal3 = {}
goal3.Position = Vector3.new(-4.451, 6.5, -210)
local goal4 = {}
goal4.Position = Vector3.new(-4.451, 6.5, -196)
local tweenInfo = TweenInfo.new(3)
local tween1Close = TweenService:Create(part, tweenInfo, goal1)
local tween2Close = TweenService:Create(part2, tweenInfo, goal2)
local tween1Open = TweenService:Create(part, tweenInfo, goal3)
local tween2Open = TweenService:Create(part2, tweenInfo, goal4)
tween1Open:Play()
tween2Open:Play()
game.Workspace.ElevatorShaft.BarrierPart.CanCollide = false
for i,v in pairs (game.Workspace.Map:GetChildren()) do
if v then
v:Destroy()
end
end
for i,v in pairs (game.Workspace.Music:GetChildren()) do
if v then
v:Stop()
end
end
local newMap = math.random(1,mapCount)
local map = game.ReplicatedStorage.Levels[newMap]:Clone()
map.Parent = workspace.Map
if newMap == 1 then
game.Workspace.Music.FastSpeed:Play()
for i,v in pairs(game.Players:GetPlayers()) do
if v.PlayerStats.Playing.Value == true then
v.Character.Humanoid.WalkSpeed = 160
task.wait(20)
v.Character.Humanoid.WalkSpeed = 16
v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
game.Workspace.Music.FastSpeed:Stop()
tween1Close:Play()
tween2Close:Play()
game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
map:Destroy()
task.wait(3)
end
end
end
if newMap == 2 then
for i,v in pairs(game.Players:GetChildren()) do
if v.PlayerStats.Playing.Value == true then
game.Workspace.Music.Lasers:Play()
wait(20)
v.Character.Humanoid.WalkSpeed = 16
v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
game.Workspace.Music.Lasers:Stop()
tween1Close:Play()
tween2Close:Play()
game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
wait(3)
map:Destroy()
end
end
end
if newMap == 3 then
game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
for i,v in pairs(game.Players:GetChildren()) do
if v.PlayerStats.Playing.Value == true then
game.Workspace.Music.High:Play()
wait(10)
v.Character.Humanoid.WalkSpeed = 16
v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
game.Workspace.Music.High:Stop()
tween1Close:Play()
tween2Close:Play()
game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
wait(3)
map:Destroy()
end
end
end
if newMap == 4 then
for i,v in pairs(game.Players:GetChildren()) do
if v.PlayerStats.Playing.Value == true then
game.Workspace.Music.RainingTacos:Play()
wait(20)
v.Character.Humanoid.WalkSpeed = 16
v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
game.Workspace.Music.RainingTacos:Stop()
tween1Close:Play()
tween2Close:Play()
game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
wait(3)
map:Destroy()
end
end
end
end