var = true flag = script.Parent script.Parent.Touched:Connect(function(hit) print(var) wait(1) if var == true then if hit.Parent ~= workspace and hit.Name ~= "Dirt" and hit.Parent.Name ~= "Model" and hit.Parent.Humanoid then var = false flag.Position = Vector3.new(0,0,0) print("move flag") clone = flag:Clone() print("cloned") clone.Parent = workspace local hrp = hit.Parent.HumanoidRootPart clone.CFrame = hrp.CFrame * CFrame.new(0,0,2) local weld = Instance.new("Weld") weld.Part0 = hrp weld.Part1 = clone weld.C0 = hrp.CFrame:Inverse() weld.C1 = clone.CFrame:Inverse() clone.Anchored = false weld.Parent = clone repeat wait(1) print(var) until false hit.Parent.Humanoid.Died:Connect(function() var = true clone:Destroy() flag.Position = Vector3.new(-60.004, 84.82, -127.496) end) end end end)
If I touch another player it sets var to true for a second and then everything breaks.