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

:MoveTo() moves to incorrect location?

Asked by 3 years ago

so i made a garden script, and everything seems to be fine but instead of moving the model to the position i want it moves it up.

local button = script.Parent
local dirt = game.Workspace.Tycoon.BioGarden.CropPole1.ZIEMIA
button.MouseButton1Click:Connect(function()
    local plr = game.Players:WaitForChild(game.Workspace:WaitForChild("PlayerName").Value)
    if button.Parent.Empty.Value == true then
        button.Parent.Level.Value = 1
        local lvl1 = game.ServerStorage.Plants:FindFirstChild(button.Parent.SelectedSeed.Value.."1"):Clone()
        lvl1.Parent = dirt
        lvl1:MoveTo(dirt.Parent.Hitbox.Position)
        while true do
            wait(math.random(2,5)*plr.PlantSpeed.Value)
            if button.Parent.Level.Value >= button.Parent.MaxLevel.Value then
                dirt:ClearAllChildren()
                button.Parent.Level.Value = button.Parent.Level.Value + 1
                local clone = game.ServerStorage.Plants:FindFirstChild(button.Parent.SelectedSeed.Value..button.Parent.Level.Value)
                clone:MoveTo(dirt.Parent.Hitbox.Position)
                clone.Parent = dirt
            end
        end
    end
end)

and here is the certain line im talking about

lvl1:MoveTo(dirt.Parent.Hitbox.Position)

any help appreciated

0
Maybe the lvl1.Parent is nil. Because I see dirt variable is the :Connect() function. Block_manvn 395 — 3y

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

Do you mean that it moves the part on top of other part? Sorry i did not fully understand but if that is the issue then i reccomend using :SetPrimaryPartCFrame()

All you gotta do is click the model you want to move and in properties set it's primary part, if this is your issue then it should help but again sorry if i did not understand you right.

0
setprimarypartcframe? also the model has a primary part which is hitbox TFlanigan 86 — 3y
0
ok after some research i understand and thx TFlanigan 86 — 3y
Ad

Answer this question