Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TextLabel isnt Growing with TweenSize?

So this code is supposed to make the GUI to be slightly bigger when your mouse is over it and when your mouse isnt over it its original size, however I keep getting the Output error:

PlayerGui.MainmenuGui.PlayButton.LocalScript:4: Expected ')' (to close '(' at column 25), got ','

Ive tried to solve this but I just cant.

ALSO: I got it working once but when it grew and shrunk it because weird shapes instead os just growing. Anyway to fix this aswell?

CODE:



local object = script.Parent
object.AnchorPoint = Vector2.new(0.5, 0.5)
object.Size = UDim2.new((0.4, 0, 0.4, 0)
 





function OnMouseHover()
--CodeHere
print("Mouse over")
object:TweenSize(UDim2.new(0.5, 0, 0.5, 0))
end)




function OnMouseNotHover()



print("Mouse leave")
object:TweenSize(UDim2.new(0.4, 0, 0.4, 0))


end)
script.Parent.MouseEnter:connect(OnMouseHover)
script.Parent.MouseLeave:connect(OnMouseNotHover)

1 comment

0

This may be wrong but I'm pretty sure it'd be Udim2.new(0.4,0,0.4, 0) without the () at the end. But also you could try doing object:TweenSizeandPosition to make it exact because when you change the size of a gui, the position moves too because the middle of the gui changes when it gets bigger or smaller.

2 answers

✓ Accepted answer

Here is what will (hopefully) work: The problem is that the tweens could be canselling out, so I made it so that the override other tweens, also fixed any () errors


local TS = game:GetService("TweenService")

local object = script.Parent
object.AnchorPoint = Vector2.new(0.5, 0.5)
object.Size = UDim2.new(0.4, 0, 0.4, 0)
local goal1 = {
	Size = UDim2.new(0.5, 0, 0.5, 0)
}
local goal2 = {
	Size = UDim2.new(0.4, 0, 0.4, 0)
}

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,)

function OnMouseHover()
--CodeHere
local tween = TS:Create(object, tweenInfo, goal1)
tween:Play()
object.TextSize = "Size18"
print("Mouse over")
end




function OnMouseNotHover()
print("Mouse leave")
local tween = TS:Create(object, tweenInfo, goal2)
tween:Play()
object.TextSize = "Size14"


end
script.Parent.MouseEnter:connect(OnMouseHover)
script.Parent.MouseLeave:connect(OnMouseNotHover)

Problems:

  • You don't need a ")" for the ends of a function that isn't anonymous.

  • You had an extra "()" on line 23 and line 06.

  • You had an extra "(".


Solutions:

  • Remove the extra ")"s.

  • Remove the extra "()" on line 23 and line 06.


Recommendations:

  • Use "local" before defining a function.

  • Use "connect" with an uppercase "C" since "connect" is deprecated. It is never a good idea to use deprecated functions.

  • Remove the extra "(".


Fixed Script:

local object = script.Parent
object.AnchorPoint = Vector2.new(0.5, 0.5)
object.Size = UDim2.new(0.4, 0, 0.4, 0)

local function onMouseHover()
	object:TweenSize(UDim2.new(0.5, 0, 0.5, 0)
	print("Mouse over")
end

local function onMouseNotHover()
	print("Mouse leave")
	object:TweenSize(UDim2.new(0.4, 0, 0.4, 0)
end

script.Parent.MouseEnter:Connect(onMouseHover)
script.Parent.MouseLeave:Connect(onMouseNotHover)

This discussion is preserved as it was. New answers, comments, and votes are closed.