Ui sets itself size to 0,0 [not solved]

i trying to make mouse hover anim on a ui and this happens

script:

local ts = game:GetService("TweenService")
local runservice = game:GetService("RunService")
local hover = false

function Lerp(a, b, t)
	return a + (b - a) * t
end

local size = script.Parent.Parent.Size

script.Parent.MouseEnter:Connect(function()
	hover = true
	local HoverFrameTween = game:GetService("TweenService"):Create(script.Parent.Parent, TweenInfo.new(0.15, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {
		Size = UDim2.fromScale(script.Parent.Parent.Size.X.Scale * 1.1, script.Parent.Parent.Size.Y.Scale * 1.1) --*1.1
	})
	HoverFrameTween:Play()
	print("enter")
end)

script.Parent.MouseLeave:Connect(function()
	hover = false
	print("leave")
	local HoverFrameTween = game:GetService("TweenService"):Create(script.Parent.Parent, TweenInfo.new(0.15, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {
		Size = UDim2.fromScale(size.X.Scale, size.Y.Scale) --*1.1
	})
	HoverFrameTween:Play()
end)

runservice.RenderStepped:Connect(function()
	if hover == true then
		ts:Create(script.Parent,TweenInfo.new(0.05),{
			Rotation = script.Parent.Rotation + 2
		}):Play()
	else
		script.Parent.Rotation = Lerp(script.Parent.Rotation, 0, 0.2)
	end
end)

Why are you using lerping?! TweenService is much easier and practical

problem not about lerp lerp plays after leave not in enter

Dumb question, but is your button in Scale? If it’s in offset, it’s attempting to multiply 0 by 1.1, which is… nothing

local TS = game:GetService("TweenService")
-- You don't need lerp or RunService for tweening
local tInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local Button = script.Parent

Button.MouseEnter:Connect(function()
  TS:Create(Button, tInfo, {["Size"] = Button:GetAttribute("HoveringSize")}):Play()
end)

Button.MouseLeave:Connect(function()
  TS:Create(Button, tInfo, {["Size"] = Button:GetAttribute("NormalSize")}):Play()
end)
local TS = game:GetService("TweenService")
local tInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local Holder = --Button holder

for _, Button in Holder:GetChildren() do -- Loop through all of the buttons in 1 script instead of adding scripts to each one
  if not Button:IsA("GuiButton") then continue end
  Button.MouseEnter:Connect(function()
    TS:Create(Button, tInfo, {["Size"] = Holder:GetAttribute("HoveringButtonSize")}):Play()
  end)

  Button.MouseLeave:Connect(function()
    TS:Create(Button, tInfo, {["Size"] = Holder:GetAttribute("NormalButtonSize")}):Play()
  end)
end

fixed it (hahahahahahhaa=13*21)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.