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

Why is my Tweening script Broken?

Asked by 7 years ago

I want to make a script for a leaderboard that tweens in or out when you press v. This is the OutPut. 12:55:43.630 - Players.Player1.PlayerGui.ScreenGui.MainOpener.open and close:7: attempt to call a userdata value

Frame = script.Parent.Parent.MainFrame
plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
mouse.KeyDown:connect(function(key)
    if key == "v" or key == "V" then
    if Frame.Position == UDim2.new(.45,0,.1,0) then
        Frame:TweenPosition(UDim2.new(1.2,0,.1,0)"Out","Bounce",1.2)
    elseif Frame.Position == UDim2.new(1.2,0,.1,0) then
        Frame:TweenPosition(UDim2.new(.45,0,.1,0)"Out","Bounce",1.2)
            end
        end
end)

1 answer

Log in to vote
0
Answered by
Cesire 45
7 years ago
Edited 7 years ago

Have you tried using this? You forgot to add a "," in both of the tweens. Also, the GetMouse() method to get Key presses is deprecated. I've fixed all of the problems here:

local UIS = game:GetService("UserInputService")
Frame = script.Parent.Parent.MainFrame
plr = game.Players.LocalPlayer
--mouse = plr:GetMouse() is deprecated!
--mouse.KeyDown:connect(function(key)
UIS.InputBegan:connect(function(i,g)
    if i.KeyCode==Enum.KeyCode.V then
    if Frame.Position == UDim2.new(.45,0,.1,0) then
        Frame:TweenPosition(UDim2.new(1.2,0,.1,0),"Out","Bounce",1.2)
    elseif Frame.Position == UDim2.new(1.2,0,.1,0) then
        Frame:TweenPosition(UDim2.new(.45,0,.1,0),"Out","Bounce",1.2)
            end
        end
end)


0
It does not work but it does not give an output ZeonMaxwelll 75 — 7y
0
Hm, have you placed it in a LocalScript? and does frame point to the correct frame? It does not work in a normal script im afraid. Cesire 45 — 7y
0
Sorry..... i had a different method of getting of getting the leaderboard there by turning the visibility off and on and i had it to start off Sorry :( ZeonMaxwelll 75 — 7y
0
It's alright. Cesire 45 — 7y
Ad

Answer this question