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

How do you tween a GUI into the screen then back off?

Asked by 4 years ago

I have a part that if touched, awards the player who touched it some cash. I am stuck trying to tween the GUI I have made onto the screen then back of again. Please help!!!

--Basically checks if the toucher of the button is a player, then adds money to that player.

local ting = 0 --debouncer

local gui = game.StarterGui.ParkourCompleted.Main


function onTouched(hit)

    if ting == 0 then --debounce check
    ting = 1 --activate debounce
    local check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button

    if check ~= nil then --If a human is found, then

        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human
        local stats = user:WaitForChild("leaderstats") --Find moneyholder

        if stats ~= nil then --If moneyholder exists then
            local cash = stats:findFirstChild("Cash") --Get money
            cash.Value  = cash.Value +100 --increase amount of money by the number displayed here (100)
            gui:TweenPosition(UDim2.new(0.306, 0,0.395, 0))
            user:LoadCharacter()
            gui:TweenPosition(UDim2.new(0.247, 0,-10, 0))
            wait(30) --wait-time before button works again
        end

    end

    ting = 0 --remove debounce
    end

end

script.Parent.Touched:connect(onTouched)

0
this is a script, so it cannot change things that are local like the playergui TheRealPotatoChips 793 — 4y
0
So if I changed the scipt to a Local Scipt, would it work? Krystal_Kyle 47 — 4y
0
change line 5 to the script.Parent version of the path greatneil80 2647 — 4y
0
Thank you soooo much!!! Krystal_Kyle 47 — 4y

Answer this question