Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI not tweening when event is fired?

Asked by
Maxis_s 97
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

0
Still doesn't work. Maxis_s 97 — 4y
0
Is it printing anything in the output? TheRealPotatoChips 793 — 4y
Ad

Answer this question