-
What do you want to achieve? I made a player on a decal (rectangle) and every time you press a key it moves forward a few pixels (creating a new rectangle on another position), and I wanted to make the player’s old position (rectangle) deleted.
-
What is the issue? There’s no issue, I need any tip to delete the old player position (rectangle).
-
What solutions have you tried so far? Tried using different functions of editable image, none of them helped
local ImageObject = script.Parent
local EditableImage = Instance.new("EditableImage")
EditableImage.Size = Vector2.one * 1024
EditableImage.Parent = ImageObject
local startPosition : Vector2 = Vector2.new(325, 150)
local updatedPosition : Vector2
EditableImage:DrawRectangle(startPosition, Vector2.new(EditableImage.Size.X/7, EditableImage.Size.Y/7), Color3.new(1, 0, 0.0156863), 0)
local uis = game:GetService("UserInputService")
local function DrawPlayer(y, x)
updatedPosition = startPosition + Vector2.new(y, x)
startPosition = updatedPosition
EditableImage:DrawRectangle(updatedPosition, Vector2.new(EditableImage.Size.X/7, EditableImage.Size.Y/7), Color3.new(1, 0, 0.0156863), 0)
end
uis.InputBegan:Connect(function(input : InputObject)
if input.KeyCode == Enum.KeyCode.W then
DrawPlayer(40, 0)
end
if input.KeyCode == Enum.KeyCode.A then
DrawPlayer(0, -40)
end
if input.KeyCode == Enum.KeyCode.S then
DrawPlayer(-40, 0)
end
if input.KeyCode == Enum.KeyCode.D then
DrawPlayer(0, 40)
end
end)