Help with my flower

The disrespect is an atrocity buddy.

5 Likes

Hey instead of using 172 tweens which can cause massive issues such as memory issues, you might want to try using Animations for this.

You can checkout this dev hub post on how to do animations on models without humanoids

https://developer.roblox.com/en-us/api-reference/class/AnimationController

5 Likes

Even though I’m not a programmer myself, I’m so sorry about all these replies. They are so disrespectful. Please ignore all the disrespectful replies. This is a Help and Feedback topic, I was expecting people to help you but instead, they just disrespect you like this. I’m very sorry about this. Every beginner has starts somewhere! Of course you will make mistakes along the way but you can fix that with the help of other people! :smiley:

Once again, I’m so sorry for all these disrespectful comments! Don’t let them demotivate you, just ignore them and continue to learn with the help of other developers! ^-^
You can ask for help anytime and our community will try our best to help you!!!

18 Likes

Are you trying to tween all of the flowers?
This would be better with loops. With this loop, you can iterate through all children inside of a folder, like so:

for index, child in pairs(workspace.MyFlowers:GetChildren()) do
    print(child.Name)
end

this prints every single child’s name inside of the workspace.MyFlowers folder.
the GetChildren() function returns a table with all the children of the instance you give it, and the loop runs through all of them individually.

you can use a table to store all of the tweeninfos you want. like so:

local infos = {
    Info1 = TweenInfo.new(); -- change to your liking
    Info2 = TweenInfo.new(); -- remember the ; though
    Info3 = TweenInfo.new(); -- etc etc
}

you can do the same with the tween goals

local goals = {
   Goal1 = {Transparency = 1}; -- change to your liking
   Goal2 = {CanCollide = false}; -- remember the ;
   Goal3 = {Color = Color3.fromRGB(255, 255, 255)}; -- etc etc
}

Now its time to loop through all the parts and apply the tween to them.
We’ll use the for loop again and loop through the parts in your folder.

for _, part in pairs(workspace.MyFlowers:GetChildren()) do -- loop through all the children
   -- now we are going to loop through all of the info and goals

    for _, info in pairs(infos) do
       -- this will loop through all of the infos we have
       -- bare with me there are a lot of loops
        for _, goal in pairs(goals) do
            -- now we have looped thorough all of the assets
            tweenService:Create(part, info, goal)
            -- this tweens each part with each info and goal
        end
    end
end

Now I’m not sure if this is what you wanted but I hope it helps. There is probably a better way to do this but idk. Feel free to ask any other questions if you need

Bassically, you give the loop at list of items and it will run individually for each item in the list which you can change properties for all of them.

local items = {
    "Test1";
    "Test2";
    "Test3"; -- always remember the ; though (you dont need it on the last one)
}

-- you can name index or item whatever you want, but item is the most important
for index, item in pairs(items) do
    print(item) 
    -- this will print Test1 and then Test2 and then Test3 etc etc
    -- then you can change each item for example
    item = 1 -- this makes every item in the list = to 1
end

You can check out more about loops here

12 Likes

The best thing to shorten code like this would be to just use a for loop to run through the children of an instance and run the specified code on them. For example

for _, flowerPart in pairs(WhiteFlower:GetChildren()) do
    TweenService:Create(flowerPart, tweenInfo, tweenGoal)
    -- other code you wish to run on said child
end

And instead of tweens you could also use an animation which would probably be easier on memory.
(I believe this would help for that Animation)

But more importantly try not to kick yourself or feel bad about your code, I can guarantee you I had very similar practices when I was first learning!

As for many other people in this thread, please take into account that everybody has to start somewhere. Although you may not like the code you should not be making them feel bad about it, instead help them improve.

Anyways I hope I was able to help! :smiley:

2 Likes

Kinda sad that you have to address that it isn’t a joke tbh. I was in your position once, we all start somewhere. Don’t let the people who don’t know how to give proper feedback get to you. You’re asking for help and the fact that you’re being bombarded with hate because of a beginner mistake makes me beyond disgusted.

Now, for the feedback portion:

I’m thinking you might want to try out animations. There is a built-in animation editor you can use, here’s a link with a tutorial:
https://developer.roblox.com/en-us/articles/using-animations-in-games

If you don’t want to use the built-in editor or want some more customizability, maybe check out Moon Animator. It has things like avatar importing and easing styles. Here’s a good resource you can use to get started:

If you are looking into creating custom rigs (like your flower), there are many options. I personally use RigEdit. Here’s a link with a tutorial and docs:

Once you have your animation ID, you could probably do something like this:

local clickDetector = script.Parent.ClickDetector
local flower = script.Parent -- wherever your flower model is
local animationController = flower.AnimationController -- wherever the animationcontroller is

local animator = Instance.new('Animator') -- create an animator, this basically allows the animation to happen
animator.Parent = animationController

local myFlowerAnimationID = 123456 -- your flower animation ID
local myFlowerAnimation = Instance.new('Animation')
myFlowerAnimation.Parent = flower
myFlowerAnimation.AnimationId = 'rbxassetid://'..tostring(myFlowerAnimationID)

local animation = animator:LoadAnimation(myFlowerAnimation) -- this creates an AnimationTrack instance which we can use to play the animation

clickDetector.MouseClick:Connect(function(player)
    animation:Play()
end)

Anyway, the most important part of all of this is to not give up. We all have to start somewhere. You are a beginner, you’re asking for help and feedback which is what should have been given, not this.

Feel free to reach out if you need any help. I, as well as many others are here to help you if you need it!

: )

6 Likes

Also very sorry that this doesn’t help with the exact problem, I’m a little confused by what the original problem was :sweat_smile:

1 Like

I feel mentally violated.

Incredible work!

3 Likes

Hey, If you are still having issues with this I would recommend this.

Looking at this part of your code,

wait(4)

ErrorTween:Play() print('It should do the tween now.')

Tween88:Play()

Tween89:Play()

Tween90:Play()

Tween91:Play()

Tween92:Play()

Tween93:Play()

Tween94:Play()

Tween95:Play()

Tween96:Play()

Tween97:Play()

Tween98:Play()

Tween99:Play()

Tween100:Play()

Tween101:Play()

Tween102:Play()

Tween103:Play()

Tween104:Play()

Tween105:Play()

Tween106:Play()

Tween107:Play()

Tween108:Play()

Tween109:Play()

ErrorTween, changed the transparency to 0, Tween109 changes the Transparency to 1. Tween109 plays right after ErrorTween. Try putting wait(2) between Tween108 and Tween109.

Hope this helps!

Ah… finally, a challenge.

Okay jokes aside, don’t feel disheartened because of some of the replies in this thread.

It’s awesome that you’re learning to script, and it’s even better that you’ve detected the flaws in your code.

The code is “long”, and “messy” - yep!

So what can you do about this? I recommend that you check out something called a “for loop”, and something called a “function.”

Bugs and errors like the one you mentioned are abundant and making “long and messy” code only exacerbates the issue.

By learning how to use for loops and functions effectively, you’ll be able to weed out the bugs, and you’ll also become a better scripter in the process!

I’m glad to see you’re learning how to script - it takes determination and perseverance.

Best of luck!

9 Likes

I’ve read the replies on this topic. It’s sad to see how many people ignore the concept of constructive criticism, they help the OP, yes, but they also insult the poster, which is what you don’t want to do.

Stop, everyone starts as a beginner, nobody will bloody want to learn anything or join a community if a large part of the community is negative towards beginner’s. Stop, just stop.

Instead, add words of encouragement with your criticism and help. Saying things like “this makes me want to cry,” or just talking with the manner of “smh, this dude is such a noob lol” is not right.

The Developer Forum was made in order to help everyone, especially beginners.

5 Likes

Screw all of these comments, seriously. I’ve never seen a larger group of people be so confidently incorrect and demeaning in my life besides when I play Rainbow Six.

As @Cristiano100 and @kz99 point out, animations may be the best alternative if you are trying to do a lot of movement operations on an object. There are plenty of tutorials on how to rig and animate a model.

6 Likes

This is pretty good for beginner code! One suggestion I would make is to clean the code up a little. People have been extremely rude about this, but in all honesty they probably weren’t any better when they started. Don’t let them discourage you and keep on trying! :smiley:

4 Likes

I barely know anything about programming, but what I do know is you should never let people stop you from trying something new or doing something you enjoy. Don’t even pay attention to the rude comments, everyone starts somewhere and the same went for them. No one’s a star overnight, don’t let anyone discourage you and you’ll shine bright like one. I wish you the best of luck in your future projects and endeavors.

POV: You’re here from twitter
Also keep up the good work bud! Don’t be afraid to ask questions now cus of these guys.

5 Likes

His code is hard to read, yeah, but you guys should actually give a try at helping him instead of just talking about how bad it is.

He’s a BEGINNER, he will make mistakes. He wouldn’t be here asking a question if he knew everything about scripting.

Anyway, don’t use tweens for this. Animations are the way to go. Someone else commented this and described how to use AnimationController.

1 Like

Hey! a much easier way would be to disable the tweens, and un Disable them when they are needed.

for example
script.Parent.Parent.Parent.Coin.Tween.Disabled = false

Seriously. We all started somewhere and this dude probably is learning by himself without anyone else to guide him.

When we were at his level, we made the same mistakes. So much toxicity under this post when this area is supposed to help others — not call their script bad.

4 Likes

Dear all of the people saying @Stanny_2003 needs to learn stuff related to scripting instead of being mean please help @Stanny_2003 learn how to improve

I am not a Lua scripter, but dear God… Even I can tell that’s a lot of code. Please do not take this as an insult, but as a step to become better. Also, instead of tweening services, try to use animations. It saves on a LOT of time, and is way more efficient. Again, please do not be disheartened, this is simply honest feedback, and take this as a lesson to learn more scripting! I’m sure you’ll succeed in no time! :grinning_face_with_smiling_eyes: