Hey, I wrote this code to get the GUI to Tween to the centre of the player’s screen when the prompt is triggered, however, the GUI seems to be veering off to the incorrect position.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tool = ReplicatedStorage:WaitForChild("ProductItems"):WaitForChild("Tool")
Prompt.Triggered:Connect(function(Player)
local Frame = Player.PlayerGui.ProductGui.Frame
if Player.PlayerGui.ProductGui.Enabled == false then
Player.PlayerGui.ProductGui.Enabled = true
Frame:TweenPosition(UDim2.new({0.33, 0},{0.232, 0}))
end
end)
No it doesnt need to change I was just wondering cause it can effect the position it goes too.
Is IgnoreGuisnet or whatever the property is called turned on?
This. For future reference, if you need to use UDim2.new, it accepts 4 optional number arguments or 2 UDim arguments:
UDim2.new(xScale, xOffset, yScale, yOffset)
-- technically works with 1 UDim argument but typed as mandatory
UDim2.new(UDim.new(xScale, xOffset), UDim.new(yScale, yOffset))
local Tool = ReplicatedStorage:WaitForChild("ProductItems"):WaitForChild("Tool")
Prompt.Triggered:Connect(function(Player)
local Frame = Player.PlayerGui.ProductGui.Frame
if Player.PlayerGui.ProductGui.Enabled == false then
Player.PlayerGui.ProductGui.Enabled = true
Frame.AnchorPoint = Vector2.new(.5,.5)
Frame:TweenPosition(UDim2.new({0.5, 0},{0.5, 0}))
end
end)