I made a sword game and i made a function which is giving money to winner. But it doesnt work
local mapstoragechild = game.Workspace.MapStorage:GetChildren()
local players = game.Players:GetPlayers()
local message = game.Workspace.Message
local rp = game.Workspace.MapStorage.Map.PlayerStorage:GetChildren()
function tpbak()
for i = 1,#rp do
rp[i].Humanoid.Health = 0
end
end
while #mapstoragechild == 1 do
local playerleft = game.Workspace.MapStorage.Map.PlayerStorage:GetChildren()
function gibmw()
local plp = playerleft:GetPlayerFromCharacter()
for i = 1, #playerleft do
plp[i].leaderstats.Money.Value = plp[i].leaderstats.Money.Value + 10
end
end
if #playerleft == 1 then
gibmw()
tpbak()
wait(2)
game.Workspace.MapStorage:ClearAllChildren()
script.Parent.Gameselect.Disabled = true
wait(3)
script.Parent.Intermission.Disabled = false
game.Workspace.Gamemode.Value = 0
message.Value = "Game Ended !"
game.Workspace.Songs.Songloop.Disabled = false
wait(1)
script.Parent.Gameselect.Disabled = false
script.Disabled = true
break
end
wait(0.1)
end
--This script making 1 player left then shut the gametime and tp players and gib rewards

4 comments
have you put it in a script or a local script?
You have to show the entire script since you didn't show what is the value of "playerleft".
ok
your script confuses me