I was making a Snake Game. For it to work I added a Local Script in the frame. The up and down works but the left and right didn't work.
The Local Script:
local chr = script.Parent.chr local plrs = game:GetService("Players") local plr = plrs.LocalPlayer local plrmouse = plr:GetMouse() plrmouse.KeyDown:Connect(function(key) if (key:byte() == 20) then --20 = Left Key if script.Parent.Visible == true then if chr.Position == not UDim2.new(0, 0, 0, 0) then chr.Position = chr.Position - UDim2.new(0, 30, 0, 0) end end elseif (key:byte() == 19) then --19 = Right Key if script.Parent.Visible == true then chr.Position = chr.Position + UDim2.new(0, 30, 0, 0) end elseif (key:byte() == 18) then --18 = Down Key if script.Parent.Visible == true then chr.Position = chr.Position + UDim2.new(0, 0, 0, 30) end elseif (key:byte() == 17) then --17 = Up Key if script.Parent.Visible == true then if chr.Position == not UDim2.new(0, 0, 0, 0) then chr.Position = chr.Position - UDim2.new(0, 0, 0, 30) end end end end)
just gonna say that it should be if not chr.Position == UDim2.new() instead of if chr.Position == not UDim2.new() and mouse.KeyDown is deprecated, so just use UserInputService
local UIS = game:GetService "UserInputService" local player = game.Players.LocalPlayer UIS.InputBegan:Connect(function(input,gameProcessedEvent) if gameProcessedEvent then return end if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.Right then -- It could be RightArrow, im not sure and i don't remember -- Your code here end end end)