Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

:MoveTo isn't working at all on one of my models?

Asked by
Cuvette 246 Moderation Voter
7 years ago

I've used it plenty of times and I understand how it works to an extent. But for some reason this time around, the model isn't moving at all. The bounding boxes are working fine around the models and change colours when i'm out of range etc... So that shows that the mouse position is fine.

I've even compared this to another script I made based on moving models and for some reason this time around it just won't move the model for me.

I've left the insert function below from my script that deals with the model following the mouse, thanks for any help.

function Insert()
    if Clicked == true then return end
    Clicked = true
    Placed = false
    local InsertedObject = game.ServerStorage.Model
    InsertedObject:Clone().Parent = game.Workspace
    InsertedObject.PrimaryPart = InsertedObject.Tile
    local SB = Instance.new("SelectionBox", Player.PlayerGui)
    SB.Color = BrickColor.new("Teal")
    SB.Name = "Place"
    SB.Adornee = InsertedObject.Tile
    while Placed == false do
        wait()
        if (Mouse.Hit.p - Player.Character.Torso.Position).magnitude <= 100 then
            if InsertedObject.Tile.Position.Y == Spawn.Position.Y+1 then
                SB.Color = BrickColor.new("Lime green")
            else
                SB.Color = BrickColor.new("Grey") 
            end
            InsertedObject:MoveTo(Vector3.new((Mouse.Hit.p.X+12.5) - (Mouse.Hit.p.X+12.5)%25, Spawn.Position.Y+19, (Mouse.Hit.p.Z+12.5) - (Mouse.Hit.p.Z+12.5)%25))
        else
            SB.Color = BrickColor.new("Lime green") 
        end 
    end
end
0
Errors? ScriptGuider 5640 — 7y
0
None at all Cuvette 246 — 7y
1
I don't understand the problem. Is it not moving at all? OldPalHappy 1477 — 7y
0
The model that contains bricks is supposed to follow the mouse. But it's not. Cuvette 246 — 7y

1 answer

Log in to vote
1
Answered by
brianush1 235 Moderation Voter
7 years ago

Since you have a primary part, you should probably use Model::SetPrimaryPartCFrame. It is much more reliable than Model::MoveTo, since you know exactly which part ends at which point.

Ad

Answer this question