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

[SOLVED] GUI won't tween after the first time tweening?

Asked by 4 years ago
Edited 4 years ago

UPDATE: I have solved the issue. I just had to move the gui parts to a local script in the player instead of run this on the server.

I have a gui that tweens position down from above the frame to show the player the rewards they earned. The gui has a done button that tweens its position back to above the frame. It all works the first time. The gui tweens down, and the done button tweens it back up but after that, next time the gui is supposed to tween down it doesn't move. There are no errors and I've put print messages in my script to see if every part is functioning. The print message after the tween still fires. Any ideas?

Running from script in ServerScriptService

local repStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")
local event = repStorage:WaitForChild("Reward")
local levelsDatabase = require(repStorage:WaitForChild("ModuleScript"))
local toolsDatabase = require(repStorage:WaitForChild("ToolsDatabase")) 

event.OnServerEvent:Connect(function(player, cash, xp)
    print("Heard reward event")
    local xCash = cash * toolsDatabase[serverStorage.RemoteData:WaitForChild(player.Name).Tool.Value]["CashMultiplier"]
    local adjustedCash = math.floor(xCash + 0.5)
    player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + adjustedCash
    serverStorage.RemoteData:WaitForChild(player.Name).XP.Value = serverStorage.RemoteData:WaitForChild(player.Name).XP.Value + xp
    if serverStorage.RemoteData:WaitForChild(player.Name).XP.Value >= levelsDatabase[player.leaderstats.Level.Value + 1]["XP"] then
        player.leaderstats.Level.Value = player.leaderstats.Level.Value + 1
        serverStorage.RemoteData:WaitForChild(player.Name).XP.Value = serverStorage.RemoteData:WaitForChild(player.Name).XP.Value - levelsDatabase[player.leaderstats.Level.Value]["XP"]
    end
    print("Preparing Gui")

    -- GUI PART STARTS HERE

    player.PlayerGui.RewardGui.Frame.Cash.Text = "$"..adjustedCash
    player.PlayerGui.RewardGui.Frame.XP.Text = xp
    player.PlayerGui.RewardGui.Frame.Frame.TextLabel.Text = "Level "..player.leaderstats.Level.Value..": "..serverStorage.RemoteData:WaitForChild(player.Name).XP.Value.."/"..levelsDatabase[player.leaderstats.Level.Value + 1]["XP"].." XP"
    player.PlayerGui.RewardGui.Frame.Frame.Bar.Frame.Size = UDim2.new((serverStorage.RemoteData:WaitForChild(player.Name).XP.Value/levelsDatabase[player.leaderstats.Level.Value + 1]["XP"]),0,1,0)
    player.PlayerGui.RewardGui.Frame:TweenPosition(UDim2.new(0.25,0,.2,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1)
    print("Gui tweened")
end)

The done button is much shorter. Running from local script inside TextButton:

local button = script.Parent

button.MouseButton1Click:Connect(function()
    button.Parent:TweenPosition(UDim2.new(0.25, 0, -1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quart, 1)
end)
0
Tried changing both tweens to just enabling and disabling the gui and even then after the first time doing it, it won't enable or disable again. iFizzics 3 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

The tweenposition function has another parameter called override, which comes after the time parameter, this basically runs the tween even if another is running which i think is happening, try using that by adding a comma and true on line 25 after the 1. Here's what I mean:

        player.PlayerGui.RewardGui.Frame:TweenPosition(UDim2.new(0.25,0,.2,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)

Tell me if it doesn't work, I'll go through some more testing.

0
It did not work. I also tried just getting rid of tween and enabling and disabling the gui instead but that didn't work either after the first time. iFizzics 3 — 4y
Ad

Answer this question