I am working on a zombie game, and I am trying to detect when the next wave starts and to reward the players alive which are stored in the alivePlrs table
Edit: Wave value is set to
local WaveValue = script.CurrentWave.Value
I am working on a zombie game, and I am trying to detect when the next wave starts and to reward the players alive which are stored in the alivePlrs table
Edit: Wave value is set to
local WaveValue = script.CurrentWave.Value
Can you tell us which line had the error?
I would, but I don’t seem to be getting one. Let me check again
Seems like it’s your last line. The GetPropertyChangedSignal. You’re not specifying what property you want the script to listen for its change. So you should specify the Value property of WaveValue.
Let me try that thank you 
Instead of using GetPropertyChangedSignal() perhaps just attach a Changed event? It would work since you seem to be using an IntValue.
WaveValue.Changed:Connect(rewardPlayers)
Like this.
Let me try that since other thing didn’t work
Didn’t work sadly I have one more idea
Could you try debugging it, is the function even running? Attach a print to it, since it should work.
Nope no prints sadly I tried changing it again to
(i will change back)
local function rewardPlayers()
print("e")
local moneyPerWave = 10
for i, v in pairs(alivePlrs) do
for i, player in pairs(game.Players:GetPlayers()) do
if player.Name == v then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 69696996969
end
end
end
WaveValue.Changed:Connect(function()
rewardPlayers()
end)
What Instance is WaveValue, since it should be working.
You need to specify which property it should detect.
NewValue:GetPropertyChangedSignal('Value'):Connect(rewardPlayers)
it has the value of “local WaveValue = script.CurrentWave.Value”
Allow me to test thanks for the suggestion
It’s not a suggestion, it’s needed because it needs a property passed with it in order for it to work.
ik it just makes me have to type more then a certain amount lol
It did not work, here is what I have
edit: might have found the issue idk lemme test
local function rewardPlayers()
print("e")
local moneyPerWave = 10
for i, v in pairs(alivePlrs) do
for i, player in pairs(game.Players:GetPlayers()) do
if player.Name == v then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 69696996969
end
end
end
WaveValue:GetPropertyChangedSignal('Value'):Connect(rewardPlayers)
Seems like you’re missing an end.
And you don’t really need the alivePlrs loop, just loop through the players and use table.find(table, username).
Im not missing end I just forgot to copy I think
Here is whole thing
local pads = script.Parent.MapVotePads
local mapBoards = script.Parent.MapBoards
local votingStatus = script.Parent.VotingStatus
local statusValue = game.ReplicatedStorage:WaitForChild("StatusValue")
local canVote = false
local maps =
{
CyberFarm = 6953791313,
Map2 = 177925016,
Map3 = 956900746
}
local WaveValue = script.CurrentWave
while wait() do
script.GameStatus.Value = "Intermission"
script.MapName.Value = ""
statusValue.Value = "Intermission"
script.CurrentWave.Value = "0"
pads.MapVote1.Votes:ClearAllChildren()
pads.MapVote2.Votes:ClearAllChildren()
pads.MapVote3.Votes:ClearAllChildren()
pads.MapVote1.VotedGui.VotedAmount.Text = ""
pads.MapVote2.VotedGui.VotedAmount.Text = ""
pads.MapVote3.VotedGui.VotedAmount.Text = ""
mapBoards.Map1.MapGui.MapImage.ImageTransparency = 1
mapBoards.Map2.MapGui.MapImage.ImageTransparency = 1
mapBoards.Map3.MapGui.MapImage.ImageTransparency = 1
mapBoards.Map1.MapGui.MapName.Text = ""
mapBoards.Map2.MapGui.MapName.Text = ""
mapBoards.Map3.MapGui.MapName.Text = ""
for i = 20, 0, -1 do
votingStatus.StatusGui.Status.Text = "Voting will begin in " .. i .. " seconds"
statusValue.Value = "Voting will begin in " .. i .. " seconds"
wait(1)
end
votingStatus.StatusGui.Status.Text = "Vote for the map"
statusValue.Value = "Vote for the map"
local keysTable = {}
for key, value in pairs(maps) do
table.insert(keysTable, key)
end
local randomKey1 = keysTable[math.random(#keysTable)]
local mapChosen1 = maps[randomKey1]
local randomKey2, mapChosen2
repeat
randomKey2 = keysTable[math.random(#keysTable)]
mapChosen2 = maps[randomKey2]
until mapChosen2 ~= mapChosen1
local randomKey3, mapChosen3
repeat
randomKey3 = keysTable[math.random(#keysTable)]
mapChosen3 = maps[randomKey3]
until mapChosen3 ~= mapChosen1 and mapChosen3 ~= mapChosen2
mapBoards.Map1.MapGui.MapImage.ImageTransparency = 0
mapBoards.Map2.MapGui.MapImage.ImageTransparency = 0
mapBoards.Map3.MapGui.MapImage.ImageTransparency = 0
mapBoards.Map1.MapGui.MapImage.Image = "rbxassetid://" .. mapChosen1
mapBoards.Map2.MapGui.MapImage.Image = "rbxassetid://" .. mapChosen2
mapBoards.Map3.MapGui.MapImage.Image = "rbxassetid://" .. mapChosen3
mapBoards.Map1.MapGui.MapName.Text = randomKey1
mapBoards.Map2.MapGui.MapName.Text = randomKey2
mapBoards.Map3.MapGui.MapName.Text = randomKey3
pads.MapVote1.VotedGui.VotedAmount.Text = "0"
pads.MapVote2.VotedGui.VotedAmount.Text = "0"
pads.MapVote3.VotedGui.VotedAmount.Text = "0"
canVote = true
local function onPadTouched(touch, pad)
if not canVote then return end
if game.Players:GetPlayerFromCharacter(touch.Parent) then
if pads.MapVote1.Votes:FindFirstChild(game.Players:GetPlayerFromCharacter(touch.Parent).Name) then
pads.MapVote1.Votes[game.Players:GetPlayerFromCharacter(touch.Parent).Name]:Destroy()
end
if pads.MapVote2.Votes:FindFirstChild(game.Players:GetPlayerFromCharacter(touch.Parent).Name) then
pads.MapVote2.Votes[game.Players:GetPlayerFromCharacter(touch.Parent).Name]:Destroy()
end
if pads.MapVote3.Votes:FindFirstChild(game.Players:GetPlayerFromCharacter(touch.Parent).Name) then
pads.MapVote3.Votes[game.Players:GetPlayerFromCharacter(touch.Parent).Name]:Destroy()
end
local touchVal = Instance.new("StringValue")
touchVal.Name = game.Players:GetPlayerFromCharacter(touch.Parent).Name
touchVal.Parent = pad.Votes
pads.MapVote1.VotedGui.VotedAmount.Text = #pads.MapVote1.Votes:GetChildren()
pads.MapVote2.VotedGui.VotedAmount.Text = #pads.MapVote2.Votes:GetChildren()
pads.MapVote3.VotedGui.VotedAmount.Text = #pads.MapVote3.Votes:GetChildren()
end
end
pads.MapVote1.Touched:Connect(function(touch)
onPadTouched(touch, pads.MapVote1)
end)
pads.MapVote2.Touched:Connect(function(touch)
onPadTouched(touch, pads.MapVote2)
end)
pads.MapVote3.Touched:Connect(function(touch)
onPadTouched(touch, pads.MapVote3)
end)
wait(15)
canVote = false
local highestVoted
for i, pad in pairs(pads:GetChildren()) do
if not highestVoted then highestVoted = pad end
if #pad.Votes:GetChildren() > #highestVoted.Votes:GetChildren() then
highestVoted = pad
elseif #pad.Votes:GetChildren() == #highestVoted.Votes:GetChildren() then
local mapsToChoose = {pad, highestVoted}
highestVoted = mapsToChoose[math.random(#mapsToChoose)]
end
end
local mapName = mapBoards["Map" .. string.gsub(highestVoted.Name, "MapVote", "")].MapGui.MapName.Text
votingStatus.StatusGui.Status.Text = mapName .. " has been voted"
statusValue.Value = mapName .. " has been voted"
script.GameStatus.Value = "Playing"
script.MapName.Value = mapName
for _, scr in pairs(game.ReplicatedStorage.Maps:GetDescendants()) do
if scr.Name == mapName then
continue
end
local clonedMap = scr:Clone()
clonedMap.Parent = workspace.Map
end
local alivePlrs = {}
for i, plr in pairs(game.Players:GetPlayers()) do
game:GetService("ContentProvider"):PreloadAsync(workspace.Map:GetDescendants())
print("Map Loaded for"..plr.Name..", teleporting all players to map!")
plr.Character.HumanoidRootPart.CFrame = workspace.Map.SpawnPart.CFrame
table.insert(alivePlrs, plr)
plr.Character.Humanoid.Died:Connect(function()
table.remove(alivePlrs, alivePlrs[plr])
for _, scr in pairs(plr.Backpack:GetDescendants()) do
if scr.ClassName ~= "Tool" then
continue
end
scr:Destroy()
end
repeat wait() until
script.CurrentWave.Value == script.CurrentWave.Value + 1
table.insert(alivePlrs, plr)
plr.Character.HumanoidRootPart.CFrame = workspace.Map.SpawnPart.CFrame
script.Pistol:Clone().Parent = plr.Backpack
end)
script.Pistol:Clone().Parent = plr.Backpack
local dss = game:GetService("DataStoreService")
local toolsDS = dss:GetDataStore("ToolsData")
local toolsFolder = game.ServerStorage.ToolsFolder
local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools") or {}
for i, toolSaved in pairs(toolsSaved) do
if toolsFolder:FindFirstChild(toolSaved) then
toolsFolder[toolSaved]:Clone().Parent = plr.Backpack
toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear
end
end
end
wait(2.5)
repeat
wait()
statusValue.Value = "Wave "..script.CurrentWave.Value.." | "..#workspace:WaitForChild("MobFolder"):GetChildren() .." zombies remaining..."
until script.CurrentWave.Value == 51 or #alivePlrs < 1
local function rewardPlayers()
print("e")
local moneyPerWave = 10
for i, v in pairs(alivePlrs) do
for i, player in pairs(game.Players:GetPlayers()) do
if player.Name == v then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 69696996969
end
end
end
WaveValue:GetPropertyChangedSignal('Value'):Connect(rewardPlayers)
if #alivePlrs < 1 then
script.GameStatus.Value = "NotPlaying"
for i,v in pairs (game.Players:GetChildren()) do
v.Character.HumanoidRootPart.CFrame = workspace.Lobby.SpawnLocation.CFrame -- clonedMap.SpawnPart.CFrame
for _, scr in pairs(v.Backpack:GetDescendants()) do
if scr.ClassName ~= "Tool" then
continue
end
scr:Destroy()
end
end
else
-- end bonus
for i, plr in pairs(game.Players:GetPlayers()) do
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + (50 * math.random(1,3))
plr.Character.HumanoidRootPart.CFrame = workspace.Lobby.SpawnLocation.CFrame -- clonedMap.SpawnPart.CFrame
for _, scr in pairs(plr.Backpack:GetDescendants()) do
if scr.ClassName ~= "Tool" then
continue
end
scr:Destroy()
end
end
end
repeat wait() until script.GameStatus.Value == "NotPlaying" or script.GameStatus.Value == "Intermission"
end
end