Need help on making Basic 2D enemy AI

Hello! i am very new to the roblox devforum, sorry about any formatting &/or wording… :innocent:

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!
    I would like to make a Very Basic Enemy AI, nothing fancy, all it does is move from the top of the screen all the way down to the bottom part

Currently my code looks like this

local enemy = script.Parent

local moveY = 0.01

game:GetService("RunService").RenderStepped:Connect(function
	enemy.Position = UDim2.new(enemy.Position.X.Scale, 0, enemy.Position.Y.Scale - moveY, 0)
end)

the enemy in question is an imagelabel with a script inside
2. What is the issue? Include screenshots / videos if possible!

it’s not moving an inch :frowning:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

my game is entirely 2D using GUIs & i don’t know what to look up …
i might try using tweens but i’m not sure…

i accept any advice! thanks!

You are trying to use the scale measurement yes? currently you have your positional data in the offset measurement, thus why nothing is work.

enemy.Position = UDim2.new(0, enemy.Position.X.Scale, 0, enemy.Position.Y.Scale - moveY)

Instead of:

enemy.Position = UDim2.new(enemy.Position.X.Scale, 0, enemy.Position.Y.Scale - moveY, 0)

Hello!
thanks for the response, unfortunately my problem turned out to be that i put ‘renderstepped’ within a server script instead of a server script

i appreciate your help, though, cheers :innocent:

1 Like