Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script is positioning a part 73 studs higher than intended when not using position or CFrame?

Asked by 5 years ago

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
0
You should be using CFrames, NOT position, when collided with another part, it would just jump ontop that part User#20388 0 — 5y

Answer this question