I thought I was getting somewhere, but for some reason, the model will move to the player once spawned, and that's it.. when you walk into the model it will move up and you can walk under it, how can I altar this to get the desired affects?
playerMouse = game:GetService("Players").LocalPlayer:GetMouse() player = game:GetService("Players") local lastHit = nil local lastTarget = nil model = workspace.Buildings.Walls.StoneWall model:MoveTo(Vector3.new(playerMouse.Hit.p)) lastTarget = playerMouse.Target playerMouse.TargetFilter = model playerMouse.Move:connect(function() if (playerMouse.Hit ~= lastHit) then lastHit = playerMouse.Hit model:MoveTo(Vector3.new(playerMouse.Hit.p)) end end)
The :MoveTo
method will act the same as changing the part's position
. If there is anything at that position already, then the entire model will be moved upwards so it isn't clipping.
A way to get around this is to set the model's PrimaryPart
property and use the :SetPrimaryPartCFrame
method to position it.
This method will set the cframe of the primary part that you've selected to the cframe you ask it to set, then it will move the entire model around it.
If you wish to lock it to the same height, use something like this:
Model:SetPrimaryPartCFrame( CFrame.new( playerMouse.Hit.X, 1, -- Y position you want it to stick too playerMouse.Hit.Z ) )