Why is this script positioning the model (or NPC) to wherever the hell it wants

ive been trying to make a boss that teleports to a specific part of the map and then does some silly stuff, but it teleports into random spots. the actual stuff the boss does works, its just that the boss is getting POSITIONED and ORIENTED incorrectly. i have been trying to fix this for the last 5 hours, scouring youtube and the devforum, and i am losing my will to do this

script: (theres more to it but this should be the relevant stuff)
Rex is the model

function hugeCrush()
	Rex:MoveTo(Vector3.new(22.7, -33.17, 58.53))
	Rex:ScaleTo(14) --tried putting this above the movement part of the script, still did not work
	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id=16241637503"
	local animtrack = hum:LoadAnimation(anim)
	--Rex:MoveTo(Vector3.new(22.55, -32.42, 57.56))
	local animtracks = hum:GetPlayingAnimationTracks()
	for _,track in pairs(animtracks) do
		track:Stop()
	end
	--Rex:PivotTo(CFrame.new(Vector3.new(22.55, -30, 57.56),Vector3.new(22.77, -10, 0)))
	--Rex:PivotTo(game.Workspace["move here idiot"].CFrame)
	print(Rex.HumanoidRootPart.Position)
	animtrack:Play()
		wait(2.06)
		task.spawn(function()
			game.ReplicatedStorage.Events.ScreenShake:FireAllClients(10)
			wait(1)
			game.ReplicatedStorage.Events.EndScreenShake:FireAllClients()
		end)
		local newshockwave = game.ServerStorage.Shockwave:Clone()
		newshockwave.Position = Vector3.new(39.031, 0.5, 29.123)
		newshockwave.Parent = workspace
		local tweeninfo = TweenInfo.new(3)
		local goal = {}
		goal.Size = Vector3.new(3,350,350)
		goal.Transparency = 1
		local tween = tweenservice:Create(newshockwave,tweeninfo,goal)
		tween:Play()
		newshockwave.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent.Name ~= "Rex Omnium" and hit.Parent.Name ~= "Mushroom Track" and hit.Parent.Name ~= "Mushroom Follow" and hit.Parent.Name ~= "True Mushroom" then
				local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
				if stompiframe == false then
					humanoid:TakeDamage(50)
					knockback(newshockwave,hit.Parent)
					task.spawn(function()
						stompiframe = true
						wait(1)
						stompiframe = false
					end)
				end
			end
		end)
		tween.Completed:Connect(function()
			newshockwave:Destroy()
		end)
	wait(2.4)
	task.spawn(function()
		game.ReplicatedStorage.Events.ScreenShake:FireAllClients(10)
		wait(1)
		game.ReplicatedStorage.Events.EndScreenShake:FireAllClients()
	end)
	local newshockwave = game.ServerStorage.Shockwave:Clone()
	newshockwave.Position = Vector3.new(6.584, 0.5, 30.764)
	newshockwave.Parent = workspace
	local tweeninfo = TweenInfo.new(3)
	local goal = {}
	goal.Size = Vector3.new(3,350,350)
	goal.Transparency = 1
	local tween = tweenservice:Create(newshockwave,tweeninfo,goal)
	tween:Play()
	newshockwave.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent.Name ~= "Rex Omnium" and hit.Parent.Name ~= "Mushroom Track" and hit.Parent.Name ~= "Mushroom Follow" and hit.Parent.Name ~= "True Mushroom" then
			local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
			if stompiframe == false then
				humanoid:TakeDamage(50)
				knockback(newshockwave,hit.Parent)
				task.spawn(function()
					stompiframe = true
					wait(1)
					stompiframe = false
				end)
			end
		end
	end)
	tween.Completed:Connect(function()
		newshockwave:Destroy()
	end)
end

also feel free to ask me for anything extra you might need for background info on this script

2 Likes

Try making the specific spots actual parts, and then use :SetPrimaryPartCFrame() on the boss model.

1 Like

tried that, ended up with the same problem (the boss is not meant to be up in the air)
image

the boss does have a few other moves that might interfere with it’s positioning, but i dont really see how they would affect it

2 Likes

Maybe the primary part of the boss model is off? ( or one isnt set )

2 Likes

the primarypart is the head
image

Is it positioned and oriented wrong the same way every time, or does it vary?

yeah
im also just trying to position it right now

1 Like