Ui not tweening

Script is located: StarterGui>ScreenGui>Frame

local object = script.Parent
object.Position = UDim2.new(1,0,0,0)

game.Workspace.LearningCenter.Stone.Primary.ClickDetector.MouseClick:Connect(function()
	object:TweenPosition(0.5,0,0.5,0, Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, 3)
end)
2 Likes

The first three arguments in GuiObject:TweenPosition() aren’t the values for a position.

Try using UDim2.new(0.5,0,0.5,0) instead of 0.5,0,0.5,0

1 Like

so like this?

local object = script.Parent
object.Position = UDim2.new(1,0,0,0)

game.Workspace.LearningCenter.Stone.Primary.ClickDetector.MouseClick:Connect(function()
	object:TweenPosition(UDim2.new(0.5,0,0.5,0) , Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, 3)
end)
1 Like

Yeah. That should indeed work.

It is not working. What is the issue with this script?

Are there any errors in the output?

Nope, should I add a print into the function to make sure its working

try doing this instead

local object = script.Parent
object.Position = UDim2.new(1,0,0,0)

game.Workspace.LearningCenter.Stone.Primary.ClickDetector.MouseClick:Connect(function()
	object:TweenPosition(UDim2.new(0.5,0,0.5,0) , “InOut”, “Bounce”, 3)
end)
1 Like

You do you, but I guess I would add a print function.

Wait a minute…

Try using a remote event?

-- server script, inside the click detector
local clickDetector = script.Parent
local remoteEvent = game.ReplicatedStorage.RemoteEvent -- insert a remote event into replicatedStorage.
clickDetector.MouseClick:Connect(function(player) -- the player that clicked it
    remoteEvent:FireClient(player) -- fires the client, which is the player.
end)

-- a local script, inside the frame.
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
 -- gets the remote event
remoteEvent.OnClientEvent:Connect(function()
    print("Hello! This event has been fired!")
    -- code to tween the frame.
end)

I just have 2 questions:
When I made it visible/invisible it worked and when I made it tween it dosent, why not?
Q2: I set the position to 0.5,0, 0.5,0 and anchorpoint to 0.5,0.5 but its not centered. Why?

Is the size’s scale value 0?

{0, something}
0 is the scale value, while something is the offset value.

If it is true, then the frame’s size might not be centered.

Try converting it to Scale
{something, 0}

something has to be between 0 and 1, though.

Here’s the code I would do, though:

-- put this code in the OnClientEvent
script.Parent:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, 3)

@akaSourDev IgnoreGuiInset only makes it so that it ignores the topbar space (if you had a frame with the size of 1,0, 1,0 and put ignore gui inset on, it would also cover the topbar (not the buttons))

@Ulxqra, did you try looking at the developer hub’s article for TweenPosition?

try my method as your answer for questions 1
And try turning on IgnoreGuiInset for Q2

None of your answers worked. How is ignoring Inset gonna help??

Sometimes it is centered, sometimes it just dosent, why?

Is there code somewhere else that is dealing with that gui?

Change your script to a ServerScript and set this (remember to follow the comments’ instructions):

local clickDetector = script.Parent; -- Reference your ClickDetector.

local function mouse_Click(player)
	
	local playerGui = player.PlayerGui;
	
	local tweenService = game:GetService("TweenService");
	
	local tweenInfo = TweenInfo.new(
		3,
		Enum.EasingStyle.Bounce,
		Enum.EasingDirection.InOut
	)
	
	local goal = {
		UDim2.new(0.5, 0, 0.5, 0);
	}
	
	local targetUI = playerGui.ScreenGui.Frame; -- Reference your UI.
	
	local finalTween = tweenService:Create(targetUI, tweenInfo, goal)
	
	finalTween:Play()
end

clickDetector.MouseClick:Connect(mouse_Click)

But why? Everything was FINE and I just added one line which was tweening and now its not working. Something is wrong with the tweening

It enables the UI from another client considering it’s a LocalScript, not on the client of the player who clicked it. The script runs perfectly but not on the client of the player who clicked it.

Ill try your script. I will see if it works

2 Likes

Where should the script be positioned in?