Hi there!
I’ve been trying to make a 2d game with a player but i dont know exactly how to move it and what’s going wrong in this script, there’s no errors in the console but the print never shows. Any ideas?
script:
-- Grab the variables.
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer:WaitForChild("PlayerGui").Game.Canvas.Player
-- Function for moving
local function onInputBegan(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.D then
Player.Position = Player.Position + Vector2.new(0,1,0,0)
print("Player has moved.")
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)