So i have this Fruit Stall, when ever you walk up to the front part and touch it a GUI will pop up on your screen with a few food items on it and when you click close the GUI will disappear. However, Its not been working the way I've intended it to so, not even touching the part can open the GUI sometimes, the closing animation works about half the time, also I've been finding that when you walk up to the stand and touch the part the closing animation will work and not the opening animation.
Here is my code:
local stall = game.Workspace.FoodStand.FrontPart local screenUI = script.Parent local FoodStallGUI = script.Parent.Gradient local foodItems = script.Parent.Parent local frame = script.Parent.Frame screenUI.Enabled = false foodItems.Enabled = false stall.Touched:Connect(function() screenUI.Enabled = true foodItems.Enabled = true frame.Size = UDim2.new(0, 1479,0, 351) frame:TweenPosition( UDim2.new(0.09, 0,0.366, 0), -- End Position "In", -- Easing Direction "Linear", -- Easing Style 1, -- Time in Seconds false ) FoodStallGUI:TweenPosition( UDim2.new(0.122, 0, 0.139, 0), -- End Position "Out", -- Easing Direction "Quint", -- Easing Style 1, -- Time in Seconds false ) end)
Here is my Button Code:
local button = script.Parent local frame = game.Players.LocalPlayer.PlayerGui.ScreenGUI.FruitStall.Gradient -- Foods local FoodStallGUI = game.Players.LocalPlayer.PlayerGui.ScreenGUI.FruitStall.Frame local t = game.Players.LocalPlayer.PlayerGui.ScreenGUI.FruitStall -- Background button.MouseButton1Click:Connect(function() print("Attempted to close") FoodStallGUI:TweenPosition( UDim2.new(0.09, 0,0, 0), "In", -- Easing Direction "Linear", -- Easing Style 1, -- Time in Seconds false ) frame:TweenPosition( UDim2.new(0.106, 0,-0.545, 0), "In", -- Easing Direction "Linear", -- Easing Style 1, -- Time in Seconds false ) t.Enabled = false print("closed") end)
Here is my explorer: Explorer Image
Here is my GUI: GUI Image
My GUI glitching out and opening with closing animation: GUI Glitch
Hello Sonnymacko,
My name is The_PumpkinPresident (formerly ZakOMGmcpe564) and I'd be happy to help you with your problem.
You're going to need a RemoteEvent, as the stall in most likely server-sided and the UI is client sided. Insert a RemoteEvent into the ReplicatedStorage and call it whatever. For this sake, I'm going to pretend it's called "OpenGui".
Then do this code once the stall is clicked:
local rs = game.ReplicatedStorage local event = rs.OpenGui OpenGui:FireClient(player)
Then, in a localscript inside of the Gui, type this:
local rs = game.ReplicatedStorage local event = rs.OpenGui OpenGui:OnClientEvent:Connect(function() local tweenservice = game:GetService("TweenService") local tweenInfo = TweenInfo.new( 1, -- time Enum.EasingStyle.Linear, -- Style Enum.EasingDirection.InOut, -- direction 0, -- when less than zero the tween will loop indefinitely false, -- tween will reverse once reaching it's goal 0 -- DelayTime ) local tween = tweenservice:Create(FloodStallGUI, tweenInfo, {Position = UDim2.new(0.09, 0,0, 0)}) tween:Play() end)
If that doesn't work, chances are the position is being altered somehow, for instance, by a UIListLayout.
Please reply to this answer is you're facing any issues.
Hope this helps!
Hello, i might be able to help,
so basically your code tells me you are tweening the food items and the frame separately...
However, tween only work one at a time, so the code starts with tweening the food items but this tween get overridden at times by the code underneath telling it to tween the frame now, this isnt a glitch its just that only your frame will tween....
To solve this, just anchor the food items gui with an offset of 0 and tween the whole frame with the food items at once, and it wont glitch, hope this helps
game.Players.LocalPlayer.PlayerGui.ScreenGui:TweenPosition(Udim2.new(1,1,1), "In", "Linear", 3, true)