I want to make something like this.
Unboxing Simulator
My Thing
Basically, when you click the model it moves you but the problem is mine sometimes is looking in the wrong direction or just going through the box
My Box Model is made up like this
Here is my script
remoteevent.OnServerEvent:Connect(function(player,Boxz)
local Selected = player:WaitForChild("Selected")
local Humanoid = WorkSpace:WaitForChild(player.Name).Humanoid
local Box = WorkSpace.Boxes:WaitForChild(tostring(Boxz))
Selected.Value = tostring(Boxz)
Humanoid:MoveTo(Box.PrimaryPart.Position - Vector3.new(0, 0, -4))
Humanoid.MoveToFinished:Wait()
print("Reached Destination")
end)
I believe the issue is caused because of the move to position offset is constant in world terms. Here is a modification which makes it relative to the direction from the box to the humanoid:
remoteevent.OnServerEvent:Connect(function(player,Boxz)
local Selected = player:WaitForChild("Selected")
local Humanoid = WorkSpace:WaitForChild(player.Name).Humanoid
local Box = WorkSpace.Boxes:WaitForChild(tostring(Boxz))
Selected.Value = tostring(Boxz)
local rootPartPos = Humanoid.RootPart.Position
local offsetDirection = rootPartPos-Box.PrimaryPart.Position
Humanoid:MoveTo(Box.PrimaryPart.Position +offsetDirection.Unit*4)
Humanoid.MoveToFinished:Wait()
print("Reached Destination")
end)
OMG YOU ARE THE BEST. Thank you so much. I have been pondering for a few hours.