Wait im trying it out in Roblox Studio
You are using a click detector meaning you are most likely running this on server. Are you firing the client when you run the program or is it all server sided?
Send the place file please.
Its working on me but then use the Complete Function what samjay22 has wrote and insert there that Size i wrote
local tween = script.Parent:TweenSize(UDim2.new(1, -10,-0.1, 28),“InOut”,“Sine”,5)
tween .Completed:Connect(function()
script.Parent.Size = UDim2.new(1, -200,-0.1, 28)
end)
script.Parent:TweenSize(UDim2.new(1, -10,-0.1, 28),“InOut”,“Sine”,5)
repeat task.wait() until script.Parent.Size == UDim2.new(1, -10,-0.1, 28)
script.Parent.Size = UDim2.new(1, -200,-0.1, 28)
Its on server, you need to run this on client.
This works the first time the problem is the script is not running again
sorry i am new to scripting, so how do i do that?
Typing up a solution, gonna send place file.
pizza.rbxl (74,1 KB)
The Problem was disabled is a bad idea to handle this, use RemoteEvents and BindableEvents instead. Its working now. I send a Event instead the Bar.Disabled = false and Bar.Disabled = true
Add me on discord please, I am going to rewrite this.
I think its better when you use Tween.Completed:Wait() without a :Connect(function()
Country Coder#2633 is my tag, I would like to show you a more efficient way to code this system. Its pretty good given you just started but I would like to offer my assistance.
It heavily depends on the context which its used.
you could possibly create a remote function which tweens the size and the position again.
Lines:
local TweenService = game:GetService("TweenService")
local Goals = {
Position = UDim2.new(0,0,0), --where the script.Parent will be after tween
Size = UDim2.new(1,1,1), --how big the script.Parent will be
}
local Tween = TweenService:Create(script.Parent, TweenInfo.new(5), Goals) --change the number 5 to the waiting time until the tween is completed
--
local function tween()
Tween:Play()
--
Tween.Completed:Wait() -- waits until the tween finished
--
script.Parent.Size = UDim2.new(1, -200,-0.1, 28) -- resets its size back to original
script.Parent.Position = UDim2.new(0, 0, 0) -- resets its position back to original
end
NOTE: Change the size and position in the goals table to the size and position you want the button to have, AND change the size of the position after the tween has finished. I put these lines in a function so you can access them by adding a simple function like the following:
script.Parent.MouseButton1Click:Connect(tween)
This will execute the tween function when the button is clicked!
Example of what it would look like if you use the MouseButton1Click function:
OH ALSO: add some debouncing so you can’t trigger the same function as it happens.
Finished Script (put it in the Button you want to tween):
local TweenService = game:GetService("TweenService")
local Goals = {
Position = UDim2.new(0,0,0), --where the script.Parent will be after tween
Size = UDim2.new(1,1,1), --how big the script.Parent will be
}
local Tween = TweenService:Create(script.Parent, TweenInfo.new(5), Goals) --change the number 5 to the waiting time until the tween is completed
local debounce = true
--
local function tween()
if debounce == true then
debounce = false
Tween:Play()
--
Tween.Completed:Wait() -- waits until the tween finished
--
debounce = true
script.Parent.Size = UDim2.new(0, 200,0, 50) -- resets its size back to original
script.Parent.Position = UDim2.new(0, 0, 0) -- resets its position back to original
end
end
script.Parent.MouseButton1Click:Connect(tween)
Now, even if you click the button multiple times, it will only be tweened if no function is currently active/executing.
Hope this helps! (took me some time to write ^^)