Gui Acting Weird

Hello!

I am having trouble creating a jumpscare as the gui is coming from the side rather than the centre of the screen. Here is my code

local val = game.Workspace.Kickdoor.Value1
local gui = script.Parent
local js = gui.Parent.jsglitch
local glitchc = game.Workspace.glitchcreep
local glitch = game.Workspace.Glitch
local jss = game.Workspace.jssound
local waitnum = math.random(0.2,3)
js.Visible = false
gui.Visible = false
js:TweenSize(UDim2.new(0.01,0,0.01,0), "Out", "Sine", 1)
js:TweenPosition(UDim2.new(0,0,0,0), "Out", "Sine", 1)

val:GetPropertyChangedSignal("Value"):Connect(function()
	if val.Value == 2 then
		gui.Visible = true
		wait(0.3)
		gui.Visible = false
		wait(0.3)
		gui.Visible = true
		wait(0.3)
		gui.Visible = false
		wait(0.3)
		gui.Visible = true
		wait (0.1)
		gui.Visible = false
		wait(waitnum)
		js.Visible = true
		wait(2)
		glitchc:Play()
		jss:Play()
		glitch:Play()
		js:TweenPosition(UDim2.new(0,0,0,0), "Out", "Sine", 0.1)
		js:TweenSize(UDim2.new(1,0,1,0), "Out", "Sine", 0.3)
		wait(0.3)
		js:TweenPosition(UDim2.new(0,0,0,600), "Out", "Sine", 0.4)
		wait(2)
		glitchc.Volume = 2.5
		wait(0.1)
		glitchc.Volume = 2.3
		wait(0.1)
		glitchc.Volume = 2
		wait(0.1)
		glitchc.Volume = 1.8
		wait(0.1)
		glitchc.Volume = 1.4
		wait(0.1)
		glitchc.Volume = 1
		wait(0.1)
		glitchc.Volume = 0.9
		wait(0.1)
		glitchc.Volume = 0.5
		wait(0.1)
		glitchc.Volume = 0.2
		wait(0.1)
		glitchc:Stop()
	end
end)

and this is the part that the issue is happening in:

js:TweenPosition(UDim2.new(0,0,0,0), "Out", "Sine", 0.1)
		js:TweenSize(UDim2.new(1,0,1,0), "Out", "Sine", 0.3)
		wait(0.3)
		js:TweenPosition(UDim2.new(0,0,0,600), "Out", "Sine", 0.4)

If anybody could resolve the issue, that would be great :]

Could you show me a screenshot of the issue?

Using the offset instead of the scale can result in problems on different device sizes, I suggest you only use scale.
Are you sure you have the positions correct?

1 Like

Okay, so, I took a look at your code and, some of the lines are really unnecessary, so, I’ve fixed the whole code for you.

local gui = script.Parent
local js = gui.Parent.jsglitch
local glitchc = game.Workspace.glitchcreep
local glitch = game.Workspace.Glitch
local jss = game.Workspace.jssound
local waitnum = math.random(0.2,3)
js.Visible = false
gui.Visible = false
js:TweenSize(UDim2.new(0.01,0,0.01,0), "Out", "Sine", 1)
js:TweenPosition(UDim2.new(0,0,0,0), "Out", "Sine", 1)

val:GetPropertyChangedSignal("Value"):Connect(function()
	if val.Value == 2 then
		for Index = 1, 6 do
			gui.Visible = true
			task.wait(0.3)
			gui.Visible = false
		end
		
		gui.Visible = true
		
		task.wait(waitnum)
		
		js.Visible = true
		
		task.wait(2)
		
		glitchc:Play()
		
		jss:Play()
		
		glitch:Play()
		
		js:TweenPosition(UDim2.new(0,0,0,0), "Out", "Sine", 0.1)
		js:TweenSize(UDim2.new(1,0,1,0), "Out", "Sine", 0.3)
		
		task.wait(0.3)
		
		js:TweenPosition(UDim2.new(0,0,0,600), "Out", "Sine", 0.4)
		
		task.wait(2)
		
		glitchc.Volume = 2.5
		
		for Index = 1, 9 do
			glitchc.Volume -= 0.2
			task.wait(0.1)
		end -- I'd recommend to do this tweening below here as alternative way, which is more easier, smooth and effective, but, it's up to you.
				
		game:GetService("TweenService"):Create(glitchc, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Volume = 0}):Play()
		
		task.wait(0.1)
		
		glitchc:Stop()
	end
end)

I believe this has to do something with your gui object’s size or these gui tween, I’d suggest to use the scale instead of the offset, since, it will fit on any devices. Try to mess with these positions until the result turns out to be good

1 Like

Unrelated to your main issue but please use tweens man… You don’t need to end up in the gifs of scripts with absolutely spammed out wait()'s