Hi, I’m currently trying to make a system where if you walk in a certain area for a bit, there will be things you can randomly encounter. I have no idea how to do this.
Now if you don’t understand my explanation above, think about pokemon. Pokemon has random encounters that work just like this.
I also want to know how to make only a certain amount of creatures encounterable in one patch of grass/area.
Every frame you can do a random number like 1 in 10000. If this is equal to 1 and you are in the right area then do a random event. Also make sure that there is no other random event already going on.
You could maybe implemented a Touched event & a debounce every time the Character touches the Grass Areas, or Region3 either one would work
Depending on what grass it is, maybe you could do something along the lines like this for separating the Pokemon?
local Part = script.Parent
local DB = false
local PokemonToCounter = {
["BootlegChance"] = 50;
["BootlegChance2"] = 10;
["BootlegChance3"] = 1;
}
local ChanceSystem = 0
for _, Chance in pairs(PokemonToCounter) do
ChanceSystem += Chance
end
Part.Touched:Connect(function(Hit)
if not DB then
DB = true
local EncounterChance = math.random(1, ChanceSystem)
if EncounterChance == 1 then
--Do the encounter thing here
end
task.wait(0.5)
DB = false
end
end)
This is just a broad example, you could implement something along the lines of this I suppose
How do you make it so that it only gives you an encounter after a random amount of time (between like 3 to 7 seconds) and you have to be walking and touching the grass. If you stop walking or leave the grass it resets the timer