How would I make an AI system that the higher a value the quicker it teleports to positions?

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 want to make an AI system kinda like FNAF where the animatronics have an int value inside of them named “levels” and the higher the level the quicker they teleport around.

  2. What is the issue? Include screenshots / videos if possible!
    I am not sure where to start.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried YT and DevForum

1 Like

well you can do SPEED * LEVEL

1 Like

How would i use that in a script, i dont understand what you mean

I have actually tried to make a FNAF styled game on roblox, except the didn’t teleport throughtout cameras they walked.

local character=script.Parent
local level=workspace.Modifiers[character.Name].Value --The character's agression level

local bootTimer=math.clamp(math.random(5,15)*(20-level),5,10)
	while true do --This loop to wait before moving at the start
		if bootTimer>0 then
			bootTimer-=1
		else break end
		task.wait(1)
	end

You could adapt this bit of code as a baseline for your way, the map is by no means perfect as it is not refined (because i never balanced it) but it will work as a base

As for teleportingthe animatronics, you can use model:PivotTo() or model.PrimaryPart.CFrame and set the goal to a pre placed position in your map

1 Like

I don’t rlly understand the script. I read through it and i don’t rlly understand it

I’ll explain the code @uriel_Gamer444 provided as an example.
We’ll go step by step.

Variables

I’m pretty sure you’ll understand this.

local character = script.Parent
local level = workspace.Modifiers[character.Name].Value

Boot timer

Here, we have declared a variable called bootTimer. This variable has been assigned the value of math.clamp(math.random(5,15) * (20 - level), 5, 10).
It looks scary to a beginner, let’s break it down.

math.clamp(x, min, max)

math.clamp is a function provided by roblox’s math module.
You can think of it as something that restricts the x variable to fit within the bounds of min and max.
If x goes below min, then x = min, If x goes above max then x = max.

math.random(5, 15) * (20 - level)

math.random() generates a number within the given range.
The number then gets multiplied by (20 - level), where level = aggression of the character
Then the final value gets clamped within (5, 10).

while loop

In this loop, we check if bootTimer > 0, if it is, then we decrease bootTimer by 1 per second. Otherwise, we break out of the loop. This serves as a starting timer for the animatronics. Hence if they are more aggressive, the timer becomes less in value.

1 Like

Ok thanks this helped me understand it a bit more, but what i still don’t understand is why you check if bootclamp > 0. Like what is that about. And what are the numbers 5,10 there for? And why do we times the thing by 20?

Also, how can i change what the max level is, is that the 20?

These are values you can change for your liking. @uriel_Gamer444 has adjusted these for himself.
The reason why we check if bootTimer is above 0 is that we have to reduce it every second. If bootTimer is less than 0, we need to break out of the loop.

1 Like

Oh ok, and what are all the numbers there for in the boot timer?

I’m sorry, I didn’t get you. Could you rephrase that for me?

1 Like

This, what are all the numbers for, like the 5,15 and the 5,10 and why times it by 20?

As I mentioned earlier, you can change these values to your liking.

1 Like

Ok, but what do the numbers mean

let’s say math.random(5, 15) returned something like 7. Then we multiply 7 with (20 - level). let’s say the level is 10, then it’s 7 * (20 - 10) which is 70.
Then we clamp 70 to fit within 5 and 10. Let’s say 10.
Then the bootTimer will last for 10 seconds.

1 Like

brother you may want to do some tutorials on basic levels of scripting before heading straight into this… especially since Roblox is your first scripting experience. (if you need to ask questions like this constantly it’s going to be a long and painful rodeo for you!)

some resources to get you started:

good luck and have fun

Im an experienced coder, i know lots of things

OHHHH, ok that makes a lot of sense, thank you for our help, i will start scripting

Experienced in what way? Do you have previous experience working somewhere? Or are you coming from any other programming languages?

1 Like

No, i have’t done any other coding languages, lua is my first. I started coding in 2021 but have gotten way better recently.