Hello, I’ve been coding this basic system for plant growth. Im trying to make it so after the plant fully grows, you can pick it up as a tool. Everything works fine until the cloning the tool into the backpack, it doesn’t clone. I’ve looked through everywhere but can’t find the answer.
--plant growth script
--plant growth script
--plant growth script
local PLANT = script.Parent
local AREA = PLANT.Parent
local AREA_CD = AREA:WaitForChild("ClickDetector")
local CD = PLANT:WaitForChild("ClickDetector")
local TS = game:GetService("TweenService")
local RS = game:GetService("ReplicatedStorage")
local PLAYERS = game:GetService("Players")
local TOOL = RS.Plants.Test_Plants:WaitForChild("Test_Plant_Tool")
local SETTINGS = require(PLANT:WaitForChild("Settings"))
local STAGE_1_TIME = SETTINGS.STAGE_1_TIME
local STAGE_2_TIME = SETTINGS.STAGE_2_TIME
local STAGE_3_TIME = SETTINGS.STAGE_3_TIME
function plantStage1(size, color)
local TWEEN_TIME = 1
local GOAL = {}
GOAL.Size = size
GOAL.Color = color
local TWEEN_INFO = TweenInfo.new(1, Enum.EasingStyle.Sine)
local PlANT_TWEEN = TS:Create(PLANT, TWEEN_INFO, GOAL)
if typeof(color) ~= "Color3" then
error("Color Variable is not a BrickColor")
return
end
if typeof(size) ~= "Vector3" then
error("Size Variable is not a Vector3")
return
end
PlANT_TWEEN:Play()
end
function plantStage2(size, color)
local TWEEN_TIME = 1
local GOAL = {}
GOAL.Size = size
GOAL.Color = color
local TWEEN_INFO = TweenInfo.new(1, Enum.EasingStyle.Sine)
local PlANT_TWEEN = TS:Create(PLANT, TWEEN_INFO, GOAL)
if typeof(color) ~= "Color3" then
error("Color Variable is not a BrickColor")
return
end
if typeof(size) ~= "Vector3" then
error("Size Variable is not a Vector3")
return
end
PlANT_TWEEN:Play()
end
function plantStage3(size, color)
local TWEEN_TIME = 1
local GOAL = {}
GOAL.Size = size
GOAL.Color = color
local TWEEN_INFO = TweenInfo.new(1, Enum.EasingStyle.Sine)
local PlANT_TWEEN = TS:Create(PLANT, TWEEN_INFO, GOAL)
if typeof(color) ~= "Color3" then
error("Color Variable is not a BrickColor")
return
end
if typeof(size) ~= "Vector3" then
error("Size Variable is not a Vector3")
return
end
PlANT_TWEEN:Play()
end
function plantGrowth()
plantStage1(Vector3.new(2, 2, 2), Color3.new(0.807843, 0.360784, 1))
task.wait(STAGE_1_TIME)
plantStage2(Vector3.new(2, 3, 2), Color3.new(1, 0.419608, 0.0823529))
task.wait(STAGE_2_TIME)
plantStage3(Vector3.new(2, 5, 2), Color3.new(0.984314, 1, 0.117647))
AREA_CD.MaxActivationDistance = 32
CD.MaxActivationDistance = 32
end
function plantClicked(player)
print("CLICEKD 1")
game.Players.PlayerAdded:Connect(function(PLR)
print("PLAYER ADDED")
PLR.CharacterAdded:Connect(function()
local BACKPACK = PLR:FindFirstChildOfClass("Backpack")
if BACKPACK then
local TOOL_CLONE = TOOL:Clone()
print("CLICKED")
TOOL_CLONE.Parent = BACKPACK
end
end)
end)
end
plantGrowth()
CD.MouseClick:Connect(plantClicked)
Feel free to ask any questions.