so I want to make a tween for a frame to shrink down on the x axis in front of the button pressed but it’s scaling to 0 for no apparent reason.
script:
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:WaitForChild("Humanoid")
local gui = script.Parent.Parent
local frame = gui.Frame
local Button = gui.DashButton
local UIS = game:GetService("UserInputService")
local CoolDown = 5
local CanDash = true
local TS = game:GetService("TweenService")
local info = TweenInfo.new(
CoolDown,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0)
local goals = {Size = UDim2.new({0, 76},{0, 10}), Position = UDim2.new({0.785, 0},{0.738, 0})}
local TimeTween = TS:Create(frame,info,goals)*emphasized text*
Button.Activated:Connect(function(hit)
if CanDash == true then
game.ReplicatedStorage.RemoteEvents.DashEvent:FireServer(hum)
TimeTween:Play()
CanDash = false
wait(CoolDown)
CanDash = true
end
end)
From what it looks like, I’m going to guess the anchor point is 0, 0, however I could be wrong.
Anyway, if the frame is not parented to the ImageLabel like @hasoco said, then do that (only if you want the frame to be constricted to the boundaries of the ImageLabel)
It works a lot better now but it still scales itself to 0
also I edited the script a tiny bit:
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:WaitForChild("Humanoid")
local gui = script.Parent.Parent
local frame = gui.DashButton.Frame
local Button = gui.DashButton
local UIS = game:GetService("UserInputService")
local CoolDown = 5
local CanDash = true
local TS = game:GetService("TweenService")
local info = TweenInfo.new(
CoolDown,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0)
local goals = {Size = UDim2.fromOffset({0, 76},{0, 10}), Position = UDim2.new({0, 0},{0.921, 0})}
local TimeTween = TS:Create(frame,info,goals)
Button.Activated:Connect(function(hit)
if CanDash == true then
frame.Size = UDim2.fromOffset({0, 76},{0, 75})
game.ReplicatedStorage.RemoteEvents.DashEvent:FireServer(hum)
TimeTween:Play()
CanDash = false
wait(CoolDown)
CanDash = true
end
end)