I have a part that is created by a script that I raise by running the below code (see Raising Part Script), and I have a script that damages the player if they touch the part as a child of this script that I clone. Upon disabling the damage script (see Damage Script), the part rises by an extra 73 studs for no reason. How do I fix this?
Raising Part Script:
local killScript = script.Killer:Clone() killScript.Parent = water wait(timetoStart) local ttf = timeToFlood-timetoStart local TweenService = game:GetService("TweenService") local goal = {} goal.Position = water.Position + Vector3.new(0, floodHeight, 0) local tweenInfo = TweenInfo.new(ttf) local tween = TweenService:Create(water, tweenInfo, goal) tween:Play() wait(ttf)
where water is the part I'm trying to raise
Damage Script:
local damageDelay = 2.5 local damagePerSecond = 5 local touchingPlayers = {} function onZoneTouchStart (part) local Player = game.Players:GetPlayerFromCharacter (part.Parent) if Player then touchingPlayers [Player] = true end end function onZoneTouchEnd (part) local Player = game.Players:GetPlayerFromCharacter (part.Parent) if Player then touchingPlayers [Player] = false end end script.Parent.Touched:Connect(onZoneTouchStart) script.Parent.TouchEnded:Connect (onZoneTouchEnd) while wait (damageDelay) do local damage = damagePerSecond / damageDelay for Player, isTouching in pairs(touchingPlayers) do if isTouching then local Character = Player.Character local Humanoid = Character:findFirstChild ("Humanoid") Humanoid:TakeDamage(damage) end end end