Hello everyone this is my first post in developer forum.
So my question are that I am trying to make a new prison game and it has bot police officers, and some different types of cars.
The problem is that I am new to programming and I know very little programming. So I learned some things from Roblox developer hub but it is not enough to make my dream game. So the thing is that I can make a following police NPC who could follow people but I can’t make it to get follow only a particular team members and cannot animate it to look like it is walking. And I do not know how to move a car but I want to make a car like jailbreak so can someone help me.
Just use a zombie from the toolbox (make sure it is not a game breaking one) instead and just change the looks of it
No I mean it will follow only the criminals team members.
Oh ok then just find a target (part) that has a parent.Humanoid and if it has a HumanoidRootPart set a varable to that, then make a local variable to the police bot’s Humanoid Object and just do Humanoid:MoveTo(Target.Position) sry for bad spelling…
Does that mean I can use a humanoidrootpart on the police bot’s humanoid and set it to Humanoid:MoveTo(Player.position) .Only I still don’t understand how to make it follow the criminal team.
just get player from character and then find the teamcolor of that player
While I don’t know how to help you make AI / NPCs, I think I can help with the vehicles. The easiest way to do it would be to take a chassis from an existing vehicle in the toolbox/library, like this one: Basic Sedan. If you are determined to make your own chassis, you will need to learn how to use constraints in Roblox Studio. However, going this route will involve a significant amount of time, programming, and trial and error. I recommend watching this series on how to make a vehicle in Roblox: https://www.youtube.com/watch?v=qBn0KmiFfQQ
This is a rather difficult undertaking, my friend. I’d recommend you take smaller bites and learn better programming skills than jumping headfirst into a game project. Try to make small demos, rather than entire games. But if you’re still convinced that you have to make this game, just use the Toolbox soldier and modify the code to target criminals.
OK I understand you want me to set the target to the criminal team like
"Local Get parent = (“Team”);wait for child (“Criminal”);
Local Get parent = (“Police humanoid”);wait for child = (“Target”);
Set Target= (“Criminal”);
Humanoid:MoveTo(Target.position);
Here is a Zombie script but I don’t know how to shoot a gun in it so it might be useless to you:
local humanoid = Police.Humanoid
Police.PrimaryPart:SetNetworkOwner(nil)
local function canSeeTarget(target)
local origin = Police.HumanoidRootPart.Position
local direction = (target.HumanoidRootPart.Position - Police.HumanoidRootPart.Position).unit * 40
local ray = Ray.new(origin, direction)
local hit, pos = workspace:FindPartOnRay(ray, Police)
if hit then
if hit:IsDescendantOf(target) then
return true
end
else
return false
end
end
local function findTarget()
local players = game.Players:GetPlayers()
local maxDistance = 40
local nearestTarget
for index, player in pairs(players) do
if player.Character then
local target = player.Character
local distance = (Police.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if distance < maxDistance and canSeeTarget(target) then
nearestTarget = target
maxDistance = distance
end
end
end
return nearestTarget
end
local function getPath(destination)
local PathfindingService = game:GetService("PathfindingService")
local pathParams = {
["AgentHeight"] = 15,
["AgentRadius"] = 4,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(Police.HumanoidRootPart.Position, destination.Position)
return path
end
local function attack(target)
local distance = (Police.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if distance > 8 then
humanoid:MoveTo(target.HumanoidRootPart.Position)
else
target.Humanoid.Health = 0
end
end
local function walkTo(destination)
local path = getPath(destination)
if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
local target = findTarget()
if target and target.Humanoid.Health > 0 then
print("TARGET FOUND", target.Name)
attack(target)
break
else
print("Moving to ", waypoint.Position)
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
else
humanoid:MoveTo(destination.Position - (Police.HumanoidRootPart.CFrame.LookVector * 10))
end
end
function patrol()
local waypoints = workspace.waypoints:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
while wait(0.25) do
patrol()
end
set police to your police model by saying local Police = script.Parent
Thank you for the help @creepersaur And @tinysam2004 I will add bits of code to edit the code according to my game.
@Firebird1cool ya you see you uhh wrote the script wrong:’
function RunCode()
--this is the zombie / police follow and kill script!
end
local Target = Criminal.HumanoidRootPart
local Player = game.Players:GetPlayerFromCharacter(Target.Parent)
if Player.TeamColor == game.Teams.Criminals.TeamColor then
RunCode()
end
Told ya I was new at coding .
@tinysam2004 I am not a very experienced with blender so I am going to use parts from the toolbox such as wheels ,chassis seats and delete their codes so that they do not break my game and make a car.
What you can do is just search “Basic Car” on toolbox because scripting a car is now really hard since Roblox updated studio so they stopped that. But the toolbox basic car has no scripts and works ( just build on top of that if you want to change it.
I have made this game with the basic car from the toolbox: Drift Car - Roblox
Yes, I didn’t use blender to make my vehicle either. I recommend skipping to video 2 in the series on rigging constraints if you are not going to use a mesh. However, your build will be different since it uses parts instead of a mesh. If you delete the scripts from a vehicle in toolbox, it may break the vehicle completely. For example, the Basic Sedan I linked requires the scripts for the vehicle to function. Otherwise, it is basically just a group of parts.
So can I use that jeep in suburban baseplate and others cars to make my game.
If you want to simply copy them into the game, yes you can. Anything in the toolbox/library that is available to you is free to use unless it contains content from someone other than the creator with their permission. (The jeep in the suburban baseplate is probably safe to use.) For the most part, any model or script is probably free to use unless it has logos from real-world companies or something similar.
Disclaimer: This is not legal advice, and you should contact an attorney for reliable information regarding copyright, trademarks, and patents.
If you want to use it as a base for your own vehicles, I know some have recommended using the base vehicles as a guideline on how to make your own, but I always found them too complicated for me.