#how to make a script that grows a part every second
1 messages · Page 1 of 1 (latest)
and heres my plant
this is just a little project im doing to help me learn coding and just for fun, and i intend to later change it so that as long as there is water, the plant grows, but once the water runs out, it stops growing and then after a time turns brown and dies
It seems like you're trying to create a script in a programming language like Lua for a game or simulation where a plant grows every second. Let's take a look at your code.
It appears that you're attempting to increase the tall variable by 1 every time the loop runs. However, there are a few issues with your code:
You're setting tall to a constant value of 1 at the beginning, which means it will never change.
You're not actually interacting with any in-game objects or utilizing any game engine-specific functions to make the plant grow.
Here's an example of how you might structure your code if you're using the Roblox Lua scripting language, assuming you have a part named "Dirt" and you want it to grow in height:
local dirt = workspace.Dirt
local tall = 1
while true do
tall = tall + 1
dirt.Size = Vector3.new(10, 10, tall) -- Adjust the size of the dirt part
wait(1) -- Wait for 1 second before the next growth
end
Keep in mind that this is a basic example, and the actual implementation may vary depending on the specifics of your game or simulation environment. Make sure to adapt the code to fit your specific context.
- if you want the water thing, just copy paste this code
local function checkWaterNearPlant()
local plantPosition = workspace.Plant.Position -- Assuming the plant's model is named "Plant"
local waterRegion = Region3.new(plantPosition - Vector3.new(5, 5, 5), plantPosition + Vector3.new(5, 5, 5))
local waterParts = workspace:FindPartsInRegion3(waterRegion, nil, math.huge)
for _, part in ipairs(waterParts) do
if part.Name == "Water" then -- Assuming water parts are named "Water"
return true
end
end
return false
end
while true do
if checkWaterNearPlant() then
-- There is water near the plant, continue growing
tall = tall + 1
dirt.Size = Vector3.new(10, 10, tall)
else
-- No water near the plant, handle withering or other behavior
break
end
wait(1)
end
This is 100% ChatGPT 💀
real
100%
Sometimes chatGPT is much better than you
I ensure that script is all correct
No error
ChatGPT code depends on user's skill
If your code generated by chatGPT is bad, then it's just ur skill issue
You couldn't explain a loop? 😭
gpt user cope