Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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!

0
USE A CODE BLOCK.png User#12753 0 — 7y
0
Please put the code in a code block, by selecting all the code and clicking the lua icon. EliteJcoombs 77 — 7y
0
Oh sorry, but still it would be appreciated if I could have an answer to my question. ArcticBandit 5 — 7y
0
You could add a script in the AI character that detects when he's been killed using the Humanoid's Died() detection. MisterMCCreeper -4 — 7y
0
im not very knowledgeable in scripting. Can u reccomend me a script? ArcticBandit 5 — 7y

1 answer

Log in to vote
-1
Answered by 7 years ago

~~~~~~~~~~~~~~~~~

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??

0
oh thanks man :) ArcticBandit 5 — 7y
0
oh wait can u format it in lua script ArcticBandit 5 — 7y
0
Here is the new script but it doesnt seem to work: ArcticBandit 5 — 7y
Ad

Answer this question