I have been working on a free for all round based fighting game where the last person standing wins the round. The game knows how to reward points to players each time they get a kill, but I also want to make the game reward points to the winner. I tried a bunch of different stuff which I thought might work but they all do absolutely nothing and result in the script not being able to proceed beyond my code. I know this is an easy fix but only to those who know a secret way that I don’t.
Here is the script that determines the winner, now make that winner get rewarded with points!
function teleport(plr)
wait(1)
– destroy player tools
for i,v in pairs(plr.Backpack:GetChildren()) do
if game.ServerStorage.Tools:FindFirstChild(v.Name) then
v:Destroy()
end
end
for i, v in pairs(plr.Character:GetChildren()) do
if v:IsA(“Tool”) then
if game.ServerStorage.Tools:FindFirstChild(v.Name) then
v:Destroy()
end
end
end
if plr.Character:FindFirstChild(“Torso”) then
plr.Character.Torso.CFrame = CFrame.new(game.Workspace.VotingSystem.SpawnBlock.Position+Vector3.new(0,3,0))
elseif plr.Character:FindFirstChild(“UpperTorso”) then
plr.Character.UpperTorso.CFrame = CFrame.new(game.Workspace.VotingSystem.SpawnBlock.Position+Vector3.new(0,3,0))
end
end
game.Players.PlayerRemoving:Connect(function(player)
local name = player.Name
if script.Parent.AlivePlayers:FindFirstChild(name) then
script.Parent.AlivePlayers:FindFirstChild(name):Destroy()
end
end)
script.Parent.AlivePlayers.ChildRemoved:Connect(function()
local playeronline = 0
for i,v in pairs(game.Players:GetPlayers()) do
playeronline = playeronline+1
end
local noofplayeralive = 0
for i, v in pairs(script.Parent.AlivePlayers:GetChildren()) do
noofplayeralive = noofplayeralive+1
end
if noofplayeralive==1 then
local name = "None"
for i,v in pairs(script.Parent.AlivePlayers:GetChildren()) do
name = v.Name
end
local winner = "The winner is "..name
--THIS IS WHERE THE SURVIVING WINNER GETS REWARDED 100 POINTS
script.Parent.Disabled = true
local map = game.Workspace.Maps:FindFirstChild(script.Parent.MapChosen.Value)
local silence = map.sound:Stop()
game.ReplicatedStorage.SendTextToPlayers:FireAllClients("Game Over")
wait(3)
game.Workspace.victory:Play()
print(winner)
game.ReplicatedStorage.SendTextToPlayers:FireAllClients(winner)
wait(3)
--local leaderstats = script.Parent.AlivePlayers.leaderstats --DIDN'T WORK
--if name ~= nil and name.Value ~= nil then --DIDN'T WORK
--leaderstats.Cash.Value = leaderstats.Cash.Value +100 --DIDN'T WORK
for i,player in pairs(script.Parent.AlivePlayers:GetChildren()) do
coroutine.wrap(function()
local plr = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.BlackScreen:FireClient(plr)
teleport(plr)
end)()
end
--script.Parent.AlivePlayers.leaderstats.Cash.Value = leaderstats.Cash.Value +100 --DIDN'T WORK
script.Parent.AlivePlayers:ClearAllChildren()
if playeronline>1 then
script.Parent.Disabled = false
end
end
end)
Go ahead and reply with your own solutions, but if you get confused or need to see what’s inside the game then let me know.