hello.
I am creating a stage for an obby, and I am using Prismatic Constraints to move a few kill bricks.
The issue that I am having though, is that when the player dies, the constraints stop moving fully.
Why is this happening?
Everything works fine, but it is only when the player dies that the constraints stop moving.
return function()
while not script.Parent do wait() end
local function updateGravity()
script.Parent.killPart.AntiGravity.Force = Vector3.new(0,script.Parent.killPart:GetMass()*workspace.Gravity,0)
end
updateGravity()
workspace.Changed:Connect(updateGravity)
while true do
local delta = script.Parent.killPart.Position-script.Parent.anchor.Position
local n = script.Parent.anchor.Attachment.WorldAxis
local axis
if math.abs(n.X) > math.abs(n.Y) and math.abs(n.X) > math.abs(n.Z) then
axis = "X"
elseif math.abs(n.Y) > math.abs(n.X) and math.abs(n.Y) > math.abs(n.Z) then
axis = "Y"
else
axis = "Z"
end
local distance = delta[axis]/n[axis]
if math.abs(distance)+1 >= math.abs(script.Parent.killPart.PrismaticConstraint.TargetPosition) and math.sign(distance) == math.sign(script.Parent.killPart.PrismaticConstraint.TargetPosition) then
script.Parent.killPart.PrismaticConstraint.TargetPosition = -script.Parent.killPart.PrismaticConstraint.TargetPosition
end
wait()
end
end
there must be a problem in this script, I think there is something breaking the “while true do” loop when the player dies
you should put a “print” command in the script’s loop run the game and then see in the output if it stops printing after the player dies.