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

Why won't won't gui animate when Key pressed?

I'm doing what it saying to do but still gives this error: game.Players.Noman538.PlayerGui.EventGui.Frame.LocalScript:10: Expected ')' (to close '(' at column 28), got ','

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Gui = script.Parent.Parent
local Frame = Gui.Frame
local CloseButton = Frame.Roundy.CloseButton

UIS.InputBegan:connect(function(P2)
	if P2.KeyCode == Enum.KeyCode.Q then
		Frame:TweenPosition(UDim2.new(0.5, 0,0.5, 0),"InOut","Sine", 1.2)
		elseif Frame.Position == (0.5, 0,0.5, 0) then
			Frame:TweenPosition(UDim2.new(0.5, 0,1.5, 0),"InOut","Sine", 1.2)
		end
	end
end)

CloseButton.MouseButton1Click:Connect(function()
	Frame:TweenPosition(UDim2.new(0.5, 0,1.5, 0),"InOut","Sine", 1.2)
end)

1 comment

0

Why is line 10 an elseif statement? Shouldn't it just be an if statement?

1 answer

✓ Accepted answer

Not tested, but try:

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Gui = script.Parent.Parent
local Frame = Gui.Frame
local CloseButton = Frame.Roundy.CloseButton

UIS.InputBegan:connect(function(P2)
    if P2.KeyCode == Enum.KeyCode.Q then
        Frame:TweenPosition(UDim2.new(0.5, 0,0.5, 0),"InOut","Sine", 1.2)
        elseif Frame.CFrame == CFrame.new(0.5, 0,0.5, 0) then
            Frame:TweenPosition(UDim2.new(0.5, 0,1.5, 0),"InOut","Sine", 1.2)
        end
    end
end)

CloseButton.MouseButton1Click:Connect(function()
    Frame:TweenPosition(UDim2.new(0.5, 0,1.5, 0),"InOut","Sine", 1.2)
end)

3 comments

0

PoppyandNevaarecute i replaced Cframe with position and Udim2 and it works ok ye cool

0

Yay!

0

yeah i would reccomend using UDim2 for ui, not cframe

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