Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why this script moves the model to incorrect position?

so i made a simple garden script which im going to improve but its in testing stage right now

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)

so it seems to be ok but instead of moving the lvl1 to hitbox position it moves it above it here is a screenshot http://prntscr.com/sshulr

1 answer

Well only reason the position is wrong is because of this line:

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

Is it the hitbox that you want to set the position to? I think you wanted the position to be the dirt dirt.Position instead.

2 comments

0

have tried and it spawned in the same location for some reason

0

it spawns on top of the entire model hitbox

This discussion is preserved as it was. New answers, comments, and votes are closed.