I have two variables, done and triggered. Both update momentarily as they are updated in the code, but immediately after they are reset. Any ideas on what's happening? I've already tried making them their own separate values, but the same thing happens.
local parPar = script.Parent.Parent
local posX = parPar.Position.X
local posY = parPar.Position.Y
local posZ = parPar.Position.Z
local done = false
local triggered = false
local function timer()
wait(1.5)
local done = true
end
script.Parent.Touched:connect(function(hit)
if not triggered then
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
if hit.Name == "Head" or hit.Parent.ClassName == "Accessory" and hit.Parent.humanoid.Jump == true and triggered == false then
local triggered = true
parPar.CanCollide = false
local head = hit.Parent.Head
local headPosY = head.Position.Y
while done == false do
local oldHeadPosY = headPosY
local headPosY = head.Position.Y
local difference = headPosY - oldHeadPosY
local sum = posY + difference
parPar.Position = Vector3.new(posX, sum, posZ)
wait()
end
parPar.Position = Vector3.new(posX, posY, posZ)
parPar.CanCollide = true
end
end
end
end)
EDIT: Forgot to mention that no errors come up in the output.

2 comments
Thank you!
No problem :)