Let the Innocents be the only ones that get the Money?Ez?

Hi everyone I’m currently working on an Round Playing Bla Bla System and rn I want the Winners to get their reward which is 250 Cash the Winner could be the Innocents or the Murderer and rn if the Murderer wins he’s the only one that gets the Cash but when the Innocents win the Innocents and the Murderer get the Money and I don’t want the Murderer to get extra Money(Ima paste the Script here which is located in the ServerScriptService)(Can y’all do a variable or sth. so the script knows the innocents r nonmurderer?idk)

--The Issue is at the End this line I think I'm not sure:   awardCash(playing, 250)

local intermission = 50
local roundLength = 180

local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status

local playingTeam = game.Teams.Playing
local lobbyTeam = game.Teams.Lobby

local murderMysteryModule = require(game.ReplicatedStorage.MurderMysterySystem)

inRound.Changed:Connect(function()
	
	if inRound.Value == true then
		
		for i, plr in pairs(game.Players:GetChildren()) do
			
			local char = plr.Character
			local humanRoot = char:WaitForChild("HumanoidRootPart")
			
			
			
			plr.Team = playingTeam
			
			char:WaitForChild("Humanoid").Died:Connect(function()
				
				plr.Team = lobbyTeam
				
				
			end)
			
		end	
		
		
	else
		
		for i, plr in pairs(game.Players:GetChildren()) do

			local char = plr.Character
			local humanRoot = char:WaitForChild("HumanoidRootPart")
			local human = char:WaitForChild("Humanoid")

			humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
			
			plr.Team = lobbyTeam
			
			human:UnequipTools()
			plr.Backpack:ClearAllChildren()
			
		end
	end	
end)



local function awardCash(players, amount)
	for _, plr in pairs(players) do
		if plr and plr:FindFirstChild("leaderstats") and plr.leaderstats:FindFirstChild("Cash") then
			plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + amount
		end
	end
end


local function round()
	while true do
		local requiredPlayers = 2

		repeat
			wait(1)
			staus.Value = "At least " .. requiredPlayers .. " players are needed to start a round"
		until #game.Players:GetChildren() >= requiredPlayers

		inRound.Value = false

		for i = intermission, 0, -1 do
			staus.Value = "Game will start in " .. i .. " seconds"
			wait(1)
		end

		inRound.Value = true
		local msg = murderMysteryModule.ChooseRoles()

		for i = roundLength, 0, -1 do
			staus.Value = "Game will end in " .. i .. " seconds"

			local playing = {}

			for i, plr in pairs(game.Players:GetChildren()) do
				if plr.Team.Name == "Playing" then
					table.insert(playing, plr)
				end
			end

			local MurdererAlive = false
			local NonMurdererAlive = false
			local murderer

			for _, playerInRound in pairs(playing) do
				local role = playerInRound:WaitForChild("Role").Value
				if role == "Murderer" then
					MurdererAlive = true
					murderer = playerInRound
				elseif role == "Innocent" then
					NonMurdererAlive = true
				end
			end

			if #playing == 0 then
				staus.Value = "Everyone Has Died"
				wait(3)
				break
			end

			if MurdererAlive and not NonMurdererAlive then
				staus.Value = murderer.Name .. " The Murderer Has Won!"
				awardCash({murderer}, 250)
				wait(3)
				break
			end

			if (not MurdererAlive and NonMurdererAlive) or (NonMurdererAlive and i == 0) then
				staus.Value = "The Innocents Have Won!"
				awardCash(playing, 250)
				wait(3)
				break
			end

			wait(1)
		end
		wait(3)
	end
end

spawn(round)

You award cash to everyone playing

awardCash(playing, 250)

That includes the murderer I assume, you need to remove the the murderer from the playing table

for i = 1, #playing do
   if playing[i] == murderer --[[This has to be the murderer]] then
      table.remove(playing, i)
   end
end
awardCash(playing, 250)

or

table.remove(playing, playing[murderer])
awardCash(playing, 250)

Try either of these.

1 Like

yo ty but there’s s a pretty small issue when the Innocents win they get the Money for 3 Seconds and when they get teleport back the money they got disappears do u think u can help pls

What does spawn round do? also are you saving the money on the server?

1 Like

ye its saving the money but idk I think the problem might be with the break function or like u said spawn(round)I got this from a tut I think spawn round returns the hole thing so a loop appears im not sure but its weird that the murderer saves the money and the innocent not

Why are you spamming so many topics? People are writing your game for you atp.

1 Like

That is weird, when they are getting teleported does it change servers? or they just get teleported to a new area and the money disappears. If the money just disappears when they get teleported to a new area in the same server then the issue is something to do with the spawn and if they get teleported to a new server its something to do with data not saving.

1 Like

dude sry but I tried doing it with some tutorials and um I’m just want to finish all this with once and I also try understand these like last time someone send me a vid bout a tutorial and I watched it.Sry if I seem a bit idk lazy and disrespectful or sth. I just need to know this with once.Sry again I’m not gonna do it again.

well ima try figure it out tomorrow but thx again for the help

ty I fixed the issue but ty again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.