Having issues with a .position script

I am trying to modify a collecting system (credit to rewtoy2015, wer on youtube: Harvest System[For Free] v0.1.3 (youtube.com)), and whenever the plant spawns, it floats. [I customized the plant to be a tree].
I have tried adding a simple system that makes the object not float using Vector3, however if I add it before, it simply does not work and still stays floating, and if I add it after, the system breaks after it spawns once.

local SpawnLocate = workspace.TreeFolder.SpawnTree

while wait(2) do
	if SpawnLocate.SpawnValue.Value == false then
		local Tree= game.ServerStorage.TreeStorage.OakTree:Clone()
		Tree.Parent = SpawnLocate
		Tree.Position = SpawnLocate.Position
                Tree.Position = Vector3.new(0,0,0) -- what I am trying to add
		SpawnLocate.SpawnValue.Value = true
	end
	if not SpawnLocate:FindFirstChild("OakTree") then
		SpawnLocate.SpawnValue.Value = false
	end
end

Error:
“Workspace.TreeFolder.SpawnTree.OakTree.Prompt.Script:28: attempt to index nil with ‘Destroy’”

set the Y position of the tree to 0 after cloning it and setting its initial position

Tree.Position = Vector3.new(Tree.Position.X, 0, Tree.Position.Z)
1 Like

Thank you! I just started developing games again and forgot part of coding, it works perfectly now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.