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

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

Asked by 4 years ago

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)
0
Why is line 10 an elseif statement? Shouldn't it just be an if statement? PoppyandNeivaarecute 134 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
0
PoppyandNevaarecute i replaced Cframe with position and Udim2 and it works ok ye cool Noman538 -2 — 4y
0
Yay! PoppyandNeivaarecute 134 — 4y
0
yeah i would reccomend using UDim2 for ui, not cframe matiss112233 258 — 4y
Ad

Answer this question