Ask a question!
Wrestling Simulator NPC Service
It seems I may have forgotten to include one of the services during this video. I apologize for this mistake and especially regret it happening during the longest video I have ever created.
Luckily for us, this was an extremely small service and it should be easy to understand. It uses the same logic for creating the proximity prompts as we used in the Data service module.
Solution
Create a module script inside of the ServerScriptService/Services folder called “NPCService.” Then insert the following code into it:
ServerScriptService/Services/NPCService.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")
local OpponentsConfig = require(ReplicatedStorage.Configs.Opponents)
local MatchService = require(ServerScriptService.Services.MatchService)
local Local = {}
local Shared = {}
function Shared.OnStart()
Local.SetupPrompts()
end
function Local.SetupPrompts()
for npc, info in OpponentsConfig.Config do
local model = Workspace.NPCs[npc]
local prompt = Instance.new("ProximityPrompt", model.PrimaryPart)
prompt.ActionText = "Fight"
prompt.ObjectText = npc
prompt.RequiresLineOfSight = false
prompt.Triggered:Connect(function(player: Player)
MatchService.StartMatch(player, npc)
end)
end
end
return Shared