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

Why is my Tweening script Broken?

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

✓ Accepted answer

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)


4 comments

0

It does not work but it does not give an output

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.

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 :(

0

It's alright.

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