Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you end a round when a player kills an NPC in Roblox Studio?

Hello, I am currently making a game in which players are put in this map where they have to kill an AI character. So far, I have everything finished for the scripts except when the players kill the NPC and the game ends. I don't have a very well knowledge of this, and I really need this help to upload the game. To be exact, I need a continuation of this script (in the post) that will end the round(say something like "Player2 has killed the Murderer" as well) when a player kills the NPC, and after, all players will be taken to the lobby(spawnlocation pad). Please reply as soon as you can.

This is the script so far:


local replicatedstorage = game:GetService("ReplicatedStorage") local status = replicatedstorage:WaitForChild("StatusValue")

while true do -- Intermission for i = 30,0,-1 do status.Value = "Intermission: "..i wait(1) end status.Value = "Game in progress" local map = game.ServerStorage.BaseMap map:Clone().Parent = game.Workspace wait(15) game.Workspace.BaseMap:Destroy() status.Value = "Game Over!" end


If there are any issues with this script, please be sure to comment on it as well. Thank you!

5 comments

0

USE A CODE BLOCK.png

0

Please put the code in a code block, by selecting all the code and clicking the lua icon.

0

Oh sorry, but still it would be appreciated if I could have an answer to my question.

0

You could add a script in the AI character that detects when he's been killed using the Humanoid's Died() detection.

0

im not very knowledgeable in scripting. Can u reccomend me a script?

1 answer


T = workspace.NPC
<pre class="brush: lua">local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")

while true do
-- Intermission
for i = 30,0,-1 do
status.Value = "Intermission: "..i
wait(1)
end
status.Value = "Game in progress"
local map = game.ServerStorage.BaseMap
map:Clone().Parent = game.Workspace
wait(15)
if T.Humanoid.Health > 0 then T:new(‘IntValue’).value = “Alive”
wait(0.2)
While true do 
wait(0)
else game.Workspace.BaseMap:Destroy()
status.Value = "Game Over!"
end

</pre>



~~~~~~~~~~~~~~~~~i dont know if this is right so just idk try to do stuff with this??

3 comments

0

oh thanks man :)

0

oh wait can u format it in lua script

0

Here is the new script but it doesnt seem to work:

This discussion is preserved as it was. New answers, comments, and votes are closed.