I have a script that sizes a part to grow bigger then back smaller on click. But I had to manually add the size into a script to change, it's very choppy and it takes too much time. Is there a different way I can do this? Also, my welds keep breaking so I'm using motor6d, is this fine too?
Thank you
TweenService - A great way to do things smoothly, change things smoothly. If you want to read more, Click Here!
Now I'll of course show you a few lines you can use but if it becomes helpful to you, please upvote! (I need that so bad...)
To tween, first of all you will need TweenService. A line of GetService
command will be enough.
local TweenService = game:GetService("TweenService")
Then let's get our part that we want to resize.
local Resize = game.Workspace.ResizeMe
Let's say we want to change it's size to 1,1,1, for that we first assign an empty table and equal it's "Size" property to 1,1,1
local Goal = {} Goal.Size = Vector3.new(1,1,1) --I want to change color as extra Goal.Color = Color3.new(0,1,0) --Green
Now we create a TweenInfo. It goes as: Time, EasingStyle, EasingDirection, a few more parameters that you better check yourself. For now, I'll just assign the time.
local TwInfo = TweenInfo.new(2)
Now we create the tween with these parameters: Object, TweenInfo and Goal. Then we play it.
local Tween = TweenService:Create(Resize, TwInfo, Goal) Tween:Play()
For more functions of TweenService, check the page. Click Here!
http://wiki.roblox.com/index.php?title=API:Class/TweenService
I made a quick demo here:
local TS = game:GetService("TweenService") local part = script.Parent local small = true local goal = {} part.ClickDetector.MouseClick:Connect(function() if small == true then small = false goal.Size = Vector3.new(4, 4, 4) --Size part should be when it's BIG local tweenInfo = TweenInfo.new(2) --Time in seconds from start to end of animation local tween = TS:Create(part, tweenInfo, goal) tween:Play() else small = true goal.Size = Vector3.new(4, 1, 2) --Size part should be when it's SMALL local tweenInfo = TweenInfo.new(2) --Time in seconds from start to end of animation local tween = TS:Create(part, tweenInfo, goal) tween:Play() end end)