Script runs in reverse

I’m a little puzzled. Because the if statement runs before the prints. But the even weirder thing here is that it’s inside an event which first runs after the child has already been put into workspace.Purchased. How come IronDropper1 is put into workspace.Purchased, the event fires, the if statement runs first & says IronDropper1 isn’t in workspace.Purchased & then first after that the prints before the if statement says IronDropper1 is indeed in workspace.Purchased.
(GA is a function to GetAttribute. Which is a string in this case.)

workspace.Purchased.ChildAdded:Connect(function(child)
	local Rebirth = GA(v,'Rebirth')
	print(workspace.Purchased:FindFirstChild(GA(v,'Item')))
	print((workspace.Purchased:FindFirstChild(GA(v,'Item'))) == nil)
	if (workspace.Purchased:FindFirstChild(GA(v,'Item'))) == nil and GA(v,'Dependency') == child.Name and Rebirth == nil or (workspace.Purchased:FindFirstChild(GA(v,'Item'))) == nil and GA(v,'Dependency') == child.Name and Rebirth <= GA(ServerStorage.Stats,'Rebirth') then
		v.Head.CanCollide = true
		print(v.Name..'but then its false')
		local Tween = TweenService:Create(v.Head, tweenInfo, Goal2)
		v.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		Tween:Play()
		Tween.Completed:Wait()
		v.Head.Transparency = 0
		if not GA(v.Parent,'Humanoid') and not v.Head:FindFirstChild('Text') then
			ButtonText(v)
		end
	end
end)

image

image

I genuinely have no idea what you’re asking for help with, but the output doesn’t show that the script is running in reverse.

2 Likes

perhaps you should attempt to clear the output or if that is not the issue then i assume the getAttribute function has a millisecond of delay before it starts to complete the formation and then print in the output

to back my idea, try creating a tick(), (either before the print lines or individually for one) then write “tick - tick()” after the print line to see if this reasoning works

1 Like

It seems like you are kind of right. Because anything without GA seemed to run before the rest no matter where in the script it was. It explains GA being slow somehow with print, but at the same time doesn’t quite make sense to me how the same GA check got fast through the if statement & printed there first before the prints above.

It also doesn’t explain how the if statement says it’s false that the child is in Purchased when it’s inside the very event ChildAdded which literally only runs because it was moved into Purchased. task.wait() seemed to fix that though it sounds stupid I need to wait in a ChildAdded event to actually see the child has been added.