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

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

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)

2 comments

0

shouldn't that be tweenposition instead of tweensize?

0

Yeah sorry I mean't TweenPosition

1 answer

✓ Accepted answer

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)

2 comments

0

Thanks it worked! And also how can I insert a blur effect?

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

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