Problem with :MoveTo on models

Hello, recently I have been trying to make a pickup and put down script but I am having trouble with ‘:MoveTo’

Here is the code

local holderValue = script.Parent.Holder.Dialog.InitialPrompt
script.Parent.MouseClick:Connect(function(player)
	if script.Parent.Pickup.Enabled == false and player.Name == holderValue then
		print("this will never show up")
	else
		holderValue = "None"
		script.Enabled = false
		script.Parent.Pickup.Enabled = true
		script.Parent.isHeld.Value = false
		script.Parent.canPickup.Value = true
		player.Character.Humanoid.JumpPower = 50
		wait(.1)
		script.Parent.Parent.Parent:MoveTo(Vector3.new(script.Parent.Parent.Position - Vector3.new(0,4.175,0))) -- This is where the problem occurs
	end
end)

The problem is basically the model’s position is set to (0,4.225,0) when the position is supposed to be set to its original position before being put down and subtracting 3.175 from its Y position.

Your code is hard to read with majority of things being named “script.Parent” and no true real names. I’m not very certain if its going to a humanoid. But :MoveTo only applies to humanoid. If you’re trying to smoothly move your object to a certain point, I recommend using TweenService + CFrame.

Thanks for the help, I’m sorry for the messy code. I just started programming with lua, 3 months ago.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.