Why isn't this script moving the parts correctly based on my value?

It is supposed to make the fish swim after another.

If the Hatched value is 1, then it is in front, if it is 2, then it is behind the other, but it does not work, why?

My coding is as follows:

while wait() do
	local Hatched = game.Players:FindFirstChild(script.Parent.Owner.Value):WaitForChild("fishHatched")
	if Hatched then
		if script.Parent.Owner.Value ~= "" and script.Parent.Owner.Value ~= nil then
			local char = game.Workspace:FindFirstChild(script.Parent.Owner.Value)
			if Hatched.Value == 1 then
				script.Parent.Part.BodyPosition.Position = char:FindFirstChild("Head").Position + Vector3.new(5,4,0)
			elseif Hatched.Value == 2 then
				script.Parent.Part.BodyPosition.Position = char:FindFirstChild("Head").Position + Vector3.new(6,4,0)
			elseif Hatched.Value == 3 then
				script.Parent.Part.BodyPosition.Position = char:FindFirstChild("Head").Position + Vector3.new(7,4,0)
			elseif Hatched.Value == 4 then
				script.Parent.Part.BodyPosition.Position = char:FindFirstChild("Head").Position + Vector3.new(8,4,0)
			elseif Hatched.Value == 5 then
				script.Parent.Part.BodyPosition.Position = char:FindFirstChild("Head").Position + Vector3.new(9,4,0)
			end
			script.Parent.Part.Rotation = Vector3.new(90, 0, 0)
		end
	end
end

Any help is greatly appreciated!

2 comments

0

What does the script do though? I need to know in order to help.

0

Sorry, but I have already figured it out, I forgot to put [SOLVED] in the title