How to make 2D type sprite movement like Purple Skittles game?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Hello, I want to make 2D type sprite movement


Purple-Skittles (2).rbxl (862.8 KB)

Like the Purple Skittles game that had made it, I tried looking through it since it is open source but I know nothing of scripting and cannot understand it.
I’d looked around and found nothing similar.

1 Like

You can change the image of the 2d image (which is facing the camera) when the user presses a certain movement key

1 Like

Change the ‘Rotation’ property of the ‘ImageLabel’ instance.

I don’t know how to do that, if you could show anything that could help would be much appreciated
I updated the post to a .rbxl file of the game that I downloaded from the website

In a LocalScript:

repeat task.wait() until game.Players.LocalPlayer.PlayerGui:FindFirstChild("ScreenGui")

local userInputService = game:GetService("UserInputService")
local sprites = {
	spriteUp = game.Players.LocalPlayer.PlayerGui.ScreenGui.SpriteUp, -- The sprite that is shown when moving up
	spriteDown = game.Players.LocalPlayer.PlayerGui.ScreenGui.SpriteDown, -- The sprite that is shown when moving down
	spriteLeft = game.Players.LocalPlayer.PlayerGui.ScreenGui.SpriteLeft, -- The sprite that is shown when moving left
	spriteRight = game.Players.LocalPlayer.PlayerGui.ScreenGui.SpriteRight -- The sprite that is shown when moving right
}

userInputService.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.W then
		for _, i in sprites do
			if i.Name ~= "SpriteUp" and i.Visible then
				i.Visible = false
			elseif i.Name == "SpriteUp" and not i.Visible then
				i.Visible = true
			end
		end
	elseif key.KeyCode == Enum.KeyCode.S then
		for _, i in sprites do
			if i.Name ~= "SpriteDown" and i.Visible then
				i.Visible = false
			elseif i.Name == "SpriteDown" and not i.Visible then
				i.Visible = true
			end
		end
	elseif key.KeyCode == Enum.KeyCode.A then
		for _, i in sprites do
			if i.Name ~= "SpriteLeft" and i.Visible then
				i.Visible = false
			elseif i.Name == "SpriteLeft" and not i.Visible then
				i.Visible = true
			end
		end
	elseif key.KeyCode == Enum.KeyCode.D then
		for _, i in sprites do
			if i.Name ~= "SpriteRight" and i.Visible then
				i.Visible = false
			elseif i.Name == "SpriteRight" and not i.Visible then
				i.Visible = true
			end
		end
	end
end)

PS: If you’re new to scripting I recommend watching this series: How To Script On Roblox 2021 - Episode 1 (Properties) - YouTube