I’m trying to tween a GUI when a player a keyboard button like “K” etc
I’ve search youtube and google but I couldn’t find what I want
here’s the script:
local player = game.Players.LocalPlayer
local AdminPanel = player:WaitForChild("PlayerGui"):WaitForChild("AdminPanel")
local List = player:WaitForChild("PlayerGui"):WaitForChild("PlayerListGui")
local UserInputService = game:GetService("UserInputService")
function tween()
AdminPanel:TweenPosition(UDim2.new(0.246, 0,0.093, 0)"Out","Linenear")
end
UserInputService.InputBegan:Connect(function(input, IsTyping)
if not IsTyping then
if input.KeyCode == Enum.KeyCode.L then
tween()
and there’s an error:
Players.dirtandra123.PlayerGui.LocalScript:10: attempt to call a UDim2 value
it didn’t work and there’s a new error, the previous error has disappeared and a new error has appeared
TweenPosition is not a valid member of ScreenGui “Players.dirtandra123.PlayerGui.AdminPanel”
seems like you’re trying to tween the ScreenGui instead of a GUI component.
create a frame, put everything you have in that GUI there and then tween that frame.
local player = game.Players.LocalPlayer
local AdminPanel = player:WaitForChild("PlayerGui"):WaitForChild("AdminPanel")
local List = player:WaitForChild("PlayerGui"):WaitForChild("PlayerListGui")
local UserInputService = game:GetService("UserInputService")
function tween()
AdminPanel:TweenPosition(UDim2.new(0.246, 0,0.093, 0), "Out", "Linear", 1, false)
end
UserInputService.InputBegan:Connect(function(input, IsTyping)
if not IsTyping then
if input.KeyCode == Enum.KeyCode.L then
tween()
You forgot the time and override type , "Out", "Linear", 1, false
local player = game.Players.LocalPlayer
local AdminPanel = player:WaitForChild("PlayerGui"):WaitForChild("AdminPanel")
local List = player:WaitForChild("PlayerGui"):WaitForChild("PlayerListGui")
local UserInputService = game:GetService("UserInputService")
function tween()
AdminPanel:TweenPosition(UDim2.new(0.246, 0,0.093, 0),"Out","Linear",false,0.2)
end
UserInputService.InputBegan:Connect(function(input, IsTyping)
if not IsTyping then
if input.KeyCode == Enum.KeyCode.L then
tween()
end
end
end)
local player = game.Players.LocalPlayer
local AdminPanel:WaitForChild("Frame"):TweenPosition(UDim2.new(0.246, 0,0.093, 0),"Out","Linear",false,0.2)
local UserInputService = game:GetService("UserInputService")
function tween()
AdminPanel:TweenPosition(Udim2.new(0.246, 0, 0.093, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 1)
end
UserInputService.InputBegan:Connect(function(keycode, IsTyping)
if not IsTyping then
if keycode.KeyCode == Enum.KeyCode.L then
tween()
end
end
end)