I am making a game where you push people off a shrinking platform in the form of rounds. In my stadium shrinking script the bug is that the stadium does not shrink to the target size instead it shrinks to (0,0,0). Also I want it to instantly end the match if there is only one player left standing. My dash system is similar to one of a battlegrounds game but it is not used as an attack. The bug is when the player dies the dashing no longer works anymore. Thanks for your help and I’m also free to suggestions on my scripts to make the game better.
Stadium Shrink Script
local replicatedStorage = game:GetService("ReplicatedStorage")
local fullyShrunkEvent = replicatedStorage:WaitForChild("IntermissionStartedEvent")
local shrinkingPart = workspace:WaitForChild("ShrinkingPart")
local lobbySpawn = workspace:WaitForChild("LobbySpawn")
local originalSize = shrinkingPart.Size
local targetSize = Vector3.new(0, 8.15, 0)
local shrinkTime = 5
local shrinkSpeed = (originalSize.X - targetSize.X) / shrinkTime
local function teleportPlayersToLobby()
local players = game:GetService("Players")
for _, player in ipairs(players:GetPlayers()) do
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
humanoidRootPart.CFrame = CFrame.new(lobbySpawn.Position)
end
end
end
end
local function regrowStadium()
shrinkingPart.Size = originalSize
end
local function shrinkStadium()
local currentTime = 0
while currentTime < shrinkTime do
shrinkingPart.Size = shrinkingPart.Size - Vector3.new(shrinkSpeed, shrinkSpeed, shrinkSpeed)
wait(1)
currentTime = currentTime + 1
end
shrinkingPart.Size = targetSize
local fullyShrunkEvent = replicatedStorage:FindFirstChild("IntermissionStartedEvent")
if fullyShrunkEvent then
fullyShrunkEvent:FireAllClients()
print("INtermissionStartedEventFired")
game.Workspace.Sounds.Battle:Stop()
end
teleportPlayersToLobby()
regrowStadium()
end
game.ReplicatedStorage.IntermissionEndedEvent.OnServerEvent:Connect(function(player)
game.Workspace.Sounds.Battle:Play()
print("INtermissionEndedEventFired")
wait(5)
shrinkStadium()
end)
Dash Script
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local humRp = char:WaitForChild("HumanoidRootPart")
local rp = game:GetService("ReplicatedStorage")
local animations = rp:WaitForChild("Animations")
local dashAnimations = animations:WaitForChild("Movement")
local camera = workspace.CurrentCamera
local gameSettings = UserSettings().GameSettings
local UIS = game:GetService("UserInputService")
local dashing = false
local db = false
local db2 = false
local cd = 1
local cd2 = 2
local allDashAnim =
{
["Left"] = dashAnimations.Left,
["Right"] = dashAnimations.Right,
["Front"] = dashAnimations.Front,
["Back"] = dashAnimations.Back
}
local function slowDash(forward,dashAnim)
local bodyV = Instance.new("BodyVelocity",humRp)
bodyV.MaxForce = Vector3.new(math.huge,0,math.huge)
local playDash = hum:LoadAnimation(dashAnim)
playDash:Play()
if forward then
for i=60,0,-1 do
bodyV.Velocity = humRp.CFrame.LookVector * i
task.wait()
end
task.delay(cd2,function()
db2 = false
end)
else
gameSettings.RotationType = Enum.RotationType.CameraRelative
for i=50,10,-1.5 do
local md = hum.MoveDirection
bodyV.Velocity = Vector3.new(md.X * i,0,md.Z * i)
task.wait()
end
task.delay(cd,function()
db = false
end)
end
playDash:Stop()
gameSettings.RotationType = Enum.RotationType.MovementRelative
bodyV:Destroy()
dashing = false
end
local function dashCheck()
if dashing == true then
wait(3)
if dashing == true then
dashing = false
end
end
end
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.Q then
print(dashing)
local md = hum.MoveDirection.Magnitude
if dashing or md <= 0 then
dashCheck()
end
print("can dash")
local MoveDirection = camera.CFrame:VectorToObjectSpace(hum.MoveDirection)
local left = math.round(MoveDirection.X) == -1
local right = math.round(MoveDirection.X) == 1
local front = math.round(MoveDirection.Z) == -1
local back = math.round(MoveDirection.Z) == 1
local forward = false
local dashAnim
if left then
if db then return end
db = true
dashAnim = allDashAnim.Left
elseif right then
if db then return end
db = true
dashAnim = allDashAnim.Right
elseif front then
if db2 then return end
forward = true
db2 = true
dashAnim = allDashAnim.Front
elseif back then
if db then return end
db = true
dashAnim = allDashAnim.Back
end
dashing = true
slowDash(forward,dashAnim)
end
end)