How to scale a frame without the UI elements moving

This works for the ScreenGui. I am currently making it work on the SurfaceGui.

gui_cut.rbxm (8.0 КБ)
Here it is.

Hmm this doesn’t seam to work, no errors or anything just doesn’t work.

What doesn’t seem to work? Could you please explain because everything works for me.

The text on the part just disappears (in your example part, I have not tried it with my GUI yet).

It just activates the “animation” upon the game starts.
Or another version I just made, without loops. Just tween.

script.Parent:TweenPosition(UDim2.new(0, 0, -1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2)
--                                                0.25 is the original position.
script.Parent.Parent:TweenPosition(UDim2.new(0, 0, .25+1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2)

Oh, I see no loop, that would make sense on why it’s not visible. Alright, I’ll try it with my setup and see if it works.

Okay, so I’ve run into a few issues when I’ve tried modifying it to work with my script. For starters, here’s the script:


local proximityPromptService = game:GetService("ProximityPromptService")

proximityPromptService.PromptShown:Connect(function(prompt)
	prompt.Prompt.SurfaceUI.Enabled = true
	prompt.Beam.Attachment1 = game.Players.LocalPlayer.Character.UpperTorso:FindFirstChild("BodyFrontAttachment")
	for i = 0, -1, -0.01 do
		prompt.Prompt.SurfaceUI.TweenFrame.Elements:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2)
		--                   Your frame position goes here \/
		prompt.Prompt.SurfaceUI.TweenFrame:TweenPosition(UDim2.new(0, 0, .25+1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2)
		task.wait()
	end
end)

proximityPromptService.PromptHidden:Connect(function(prompt)
	prompt.Prompt.SurfaceUI.Enabled = false
	prompt.Beam.Attachment1 = nil
	for i = 0, -1, -0.01 do
		prompt.Prompt.SurfaceUI.TweenFrame.Elements:TweenPosition(UDim2.new(0, 0, -1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2)
		--                   Your frame position goes here \/
		prompt.Prompt.SurfaceUI.TweenFrame:TweenPosition(UDim2.new(0, 0, .25+1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2)
		task.wait()
	end
end)

Here’s an example video showing my issue:


One of the issues is the whole prompt is moving rather than the prompt staying but the frame moving to look like it’s being cut off. Also, it doesn’t seam to be tweeting when the prompt hides.

I found out a better way to do it with UIGradient.

local delta = 0.01

-- top cut to down

for i = 0, 1, delta do
	script.Parent.UIGradient.Transparency = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 1),
		NumberSequenceKeypoint.new(i, 1),
		NumberSequenceKeypoint.new(math.min(i+delta, 1), 0),
		NumberSequenceKeypoint.new(1, 0)
	})
	task.wait()
end


-- backwards

for i = 1, 0, -delta do
	script.Parent.UIGradient.Transparency = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 1),
		NumberSequenceKeypoint.new(i, 1),
		NumberSequenceKeypoint.new(math.min(i+delta, 1), 0),
		NumberSequenceKeypoint.new(1, 0)
	})
	task.wait()
end

You should remove the loop if you’re using the tween-position method.

1 Like

Hmm still having issues, here’s my layout for the UI, should I change the ordering of anything?
image

At the PromptShown event, set the position of Elements to UDim2.new(0, 0, -1, 0), TweenFrame to UDim2.new(0, 0, “original y”+1, 0). No tween.
Then tween it all to original positions.

This doesn’t work when you have multiple UI elements like I have

Okay so this at least got it so that it goes in the right direction now, so thank you for that. The problem is still, that it does not go down when you walk away from the prompt, rather it goes down when you walk back to it again. Also still having the issue where the UI parts are moving, rather than the effect of them staying in place when the frame moves.
See below:

It would be easier for me to work with the ProximityPrompt model, so could you give me it please?

Door In workspace, Script in Starter Player Scripts.rbxm (102.6 KB)

Here’s the model for the door, and the script.