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

How can I make a TweenSize out of this GUI by going up/down?

Asked by
fr2013 88
5 years ago

How can I TweenSize the GUI when the a player comes in contact with a certain brick and it comes down but when they leave if the magnitude is less than 5, it goes away by going up. My GUI is called "Shop" and it's inside of the script.

function touch(hit)
    if game.Players:findFirstChild(hit.Parent.Name) ~= nil then
        local player = game.Players[hit.Parent.Name]
        if player.PlayerGui:findFirstChild("Shop") == nil then
            local gui = script.Shop:clone()
            gui.Parent = player.PlayerGui
            repeat
                wait()
            until (player.Character.HumanoidRootPart.Position - script.Parent.Position).magnitude > 5
            gui:remove()
        end
    end
end

script.Parent.Touched:connect(touch)
0
shouldn't that be tweenposition instead of tweensize? theking48989987 2147 — 5y
0
Yeah sorry I mean't TweenPosition fr2013 88 — 5y

1 answer

Log in to vote
0
Answered by
xEmmalyx 285 Moderation Voter
5 years ago

A simple fix to this would be to TweenPosition it or TweenSizeAndPosition if you want it to grow and move onto your screen.

In this example I use TweenPosition for simplicity and efficiency however you may edit it to your liking.

Example of Studio Setup

Script Inside Part

local Delay = 3 -- Time it takes to scroll down / up

function onTouch(hit)

    if game.Players:FindFirstChild(hit.Parent.Name) then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if not player.PlayerGui:FindFirstChild("Shop") then
            local gui = script.Shop:Clone()
            gui.Parent = player.PlayerGui

            gui.Frame:TweenPosition(UDim2.new(.5,0,.5,0),"Out","Quad",Delay,true)
            repeat wait() until (player.Character.HumanoidRootPart.Position - script.Parent.Position).magnitude > 5

            gui.Frame:TweenPosition(UDim2.new(.5,0,-.5,0),"Out","Quad",Delay,true)
            wait(Delay)
            gui:Remove()
        end
    end

end

script.Parent.Touched:Connect(onTouch)
0
Thanks it worked! And also how can I insert a blur effect? fr2013 88 — 5y
0
I'm not too familiar with such things but perhaps a reading of this would help? https://developer.roblox.com/api-reference/class/BlurEffect xEmmalyx 285 — 5y
Ad

Answer this question