Can't move ImageLabel

Hi.

  1. What do you want to achieve? Making my image label move

  2. What is the issue? I can’t move my ImageLabel for my 2D game.

  3. What solutions have you tried so far? I tried using UDim2 positions, but it still gives me errors.

local userInputService = game:GetService("UserInputService")
local character = script.Parent

userInputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.W then
		character.Position += UDim2.new(0, -1)
	end

	if input.KeyCode == Enum.KeyCode.A then
		character.Position += UDim2.new(1, 0)
	end

	if input.KeyCode == Enum.KeyCode.S then
		character.Position += UDim2.new(0, 1)
	end
	
	if input.KeyCode == Enum.KeyCode.D then
		character.Position += UDim2.new(-1, 0)
	end
end)

Also, sorry for my bad grammar.

I solved it myself, but now the image keeps disappearing when I move and I get no errors

Oh wait I found solution lol

bro what is this requirement of making longer posts

okay, input is very bad, it doesn’t let me repeat it.

I’m not sure if you completely fixed it, but based off what you posted, you could try:

local userInputService = game:GetService("UserInputService")
local character = script.Parent

userInputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.W then
		character.Position += UDim2.new(0,0, 0,-10)
	end

	if input.KeyCode == Enum.KeyCode.A then
		character.Position += UDim2.new(0,-10, 0,0)
	end

	if input.KeyCode == Enum.KeyCode.S then
		character.Position += UDim2.new(0,0, 0,10)
	end

	if input.KeyCode == Enum.KeyCode.D then
		character.Position += UDim2.new(0,10, 0,0)
	end
end)

It was moving before, but because of how you had your values it was moving way too far and going off-screen.

3 Likes

Oh I fixed it in like some days ago. Thank you anyways.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.