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

model moveto not working how i want it to?

Asked by
Plieax 66
5 years ago

I want the house to duplicate to the position of the slot but if there is a player where the house will duplicate then the house will be floating above where the players head is. How do i stop this?

        local newhouse = casas.Casa1Left:Clone()
        newhouse.Name = "clonedhouse"
newhouse.Parent = this
newhouse:MoveTo(Vector3.new(this.Position.X,this.Position.Y,this.Position.Z))
    elseif this.houseval.Value == 2 then
        this.hashouse.Value = true
        local newhouse = casas.Casa2Left:Clone()
        newhouse.Name = "clonedhouse"
newhouse.Parent = this

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

That's because MoveTo() tries to find an empty space for the model, just like setting a part's Position.

And same as in parts, if you set CFrame instead, it will not do that.

So, what you need to do is use SetPrimaryPartCFrame() function of the model, but first set its PrimaryPart in properties!

    local newhouse = casas.Casa1Left:Clone()
    newhouse.Name = "clonedhouse"
    newhouse.Parent = this
    newhouse:SetPrimaryPartCFrame(this.CFrame)
elseif this.houseval.Value == 2 then
    this.hashouse.Value = true
    newhouse.Name = "clonedhouse"
    newhouse.Parent = this
Ad

Answer this question