#Gui Elements being moved gets slower over time (Deltarune Ch 3 Spoilers)
1 messages · Page 1 of 1 (latest)
Battle System Script
Projectile Script
local battleSystem = script.Parent.Parent.Parent.Parent.BattleSystem
local battlebox = script.Parent.Parent
local soul = battlebox.Soul
local grazeCooldown = 0
local yVel = 0
while task.wait() do
grazeCooldown -= 1
if script.Parent and (soul.AbsolutePosition - script.Parent.AbsolutePosition).Magnitude < 20 then
if battleSystem.InvisFrames.Value <= 0 then
game.Players.LocalPlayer.Character.Humanoid.Health -= 10
battleSystem.InvisFrames.Value = 50
game.SoundService.Damage:Play()
end
script.Parent:Destroy()
end
if script.Parent and (soul.AbsolutePosition - script.Parent.AbsolutePosition).Magnitude < 50 then
if battleSystem.InvisFrames.Value <= 0 and grazeCooldown <= 0 then
battleSystem.TP.Value += 1
soul.Graze:Play()
soul.GrazeArea.ImageTransparency = 0
grazeCooldown = 100
end
end
if script.Parent and battleSystem.PlayerTurn.Value or script.Parent and script.Parent.Position.Y.Scale > 1.43 then
script.Parent:Destroy()
end
yVel += 0.00005
if script.Parent then
script.Parent.Position += UDim2.new(0,0,yVel,0)
end
end
Make sure that the spawning script does not edit a value outside of the function
this is the spawn portion of the BattleSystem script
if attack.Value == 1 then
local dropClones = 0
repeat
local clone = script.Drop:Clone()
clone.Parent = battlebox
clone.LocalScript.Enabled = true
clone.Position = UDim2.new(math.random(0,900)/1000,0,-0.31,0)
dropClones += 1
wait(0.1)
clone = nil
until dropClones >= 95
end
I tried changing everything to just wait() instead of task.wait() since task.wait() is fps based but it was still slowing down
alright
i don't think it would be a spawn issue since when the projectile reaches the bottom of the screen or the player's turn ends then the projectile would get destroyed
i actually increased the spawn rate and the lag still started at the same time it usually did
if anyone wants to try and fix it then here's the fight world file
you spawn the projectiles one by one with a delay of 0.1 seconds each, this means it takes about 9.5 seconds to spawn all projectiles each turn. a lot of projectiles are active at once during that time and each projectile has its own running loop. Having so many will slow down the game making the projectiles move slower every turn
all the projectiles get removed when the player's turn starts and when one of the projectiles touch the bottom of the screen then it gets destroyed so this wouldn't really happen