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

GUI not tweening when event is fired?

So, I made this script to resize a GUI to make a transition, but it doesn't work.

SCRIPTS:

Script 1: Part Script (Server Script)

local db = true

script.Parent.Touched:Connect(function(hit)
	if db == true then
		print("Part hit")
		local h = hit.Parent:FindFirstChild("Humanoid")
		if h ~= nil then
			db = false
			print("Humanoid detected")
			local plrName = hit.Parent.Name
			local plr = game.Players:FindFirstChild(plrName)
			if plr ~= nil then
				print("Player detected")
				local event = game.ReplicatedStorage.Events.DoorEntered:FireClient(plr,h,db)
				wait(5)
				db = true
			end
		end
	end
end)

Script 2: Event Script (Local Script, inside StarterPlayerScripts)

events.DoorEntered.OnClientEvent:Connect(function()
	local plr = game.Players.LocalPlayer
	local gui = game.StarterGui.TransitionGUI
	local ts = game:GetService("TweenService")
	
	local tweenInfo = TweenInfo.new(
		1, -- Time
		Enum.EasingStyle.Quad, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)
	 
	local tween = ts:Create(gui.bottom, tweenInfo, {Position = UDim2.new(1,0,0.5,0)})
	tween:Play()
	
	local tween = ts:Create(gui.top, tweenInfo, {Position = UDim2.new(1,0,0.5,0)})
	tween:Play()
	
	local tween = ts:Create(gui.right, tweenInfo, {Position = UDim2.new(0.5,0,1,0)})
	tween:Play()
	
	local tween = ts:Create(gui.left, tweenInfo, {Position = UDim2.new(0.5,0,1,0)})
	tween:Play()
end)

ADDITIONAL INFO:

  • No errors in output
  • Event in an "Events" folder in ReplicatedStorage
  • Part is a union

1 answer

The problem is that you don't need to use TweenServeice when you tween a GUI. Change the second script to this:

events.DoorEntered.OnClientEvent:Connect(function()
    local plr = game.Players.LocalPlayer
    local gui = game.StarterGui.TransitionGUI
    
    gui.bottom:TweenPosition(UDim2.new(1, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, false)
    
    gui.top:TweenPosition(UDim2.new(1, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, false)
    
    gui.right:TweenPosition(UDim2.new(0.5, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, false)
    
    gui.left:TweenPosition(UDim2.new(0.5, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, false)
    
end)

When we use :TweenPosition(), we write the End Position, then the EasingDirection, then the EasingStyle, then the timer, then the override. There is not a place for the Delay Timer or the Repeat Count.

Hope this helped!

2 comments

0

Still doesn't work.

0

Is it printing anything in the output?

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