This is supposed to make it so that when i say !outscore (number here) the players who reach that number of wipeouts must be put back into team white and his tools in the starterpack must be removed.
local isAdmin = {["Incrility"] = true} function findPlayer(name) for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end function onChatted(message) if message:sub(1, 10) == "!outscore " and isAdmin[player.Name] then local block = (message:sub(11)) end end function onHumanoidDied(humanoid, player) local stats = player:findFirstChild("leaderstats") if stats ~= nil then local deaths = stats:findFirstChild("Wipeouts") deaths.Value = deaths.Value + 1 if deaths.Value > block then player.TeamColor=BrickColor.new("White") end if deaths.Value > block then a = game.Players:GetChildren() pack=game.StarterPack:GetChildren() if #pack>0 then for i=1,#pack do pack[i]:destroy() end end end
Why is this not working Please do help.
You need to change the block variable to global (or define the local variable at the beginning and set it there). Your onHumanoidDied function can't see block. Also, you can consolidate the two if statements on lines 25 and 28. Once that's fixed, it'll look something like this.
local isAdmin = {["Incrility"] = true} local block --make block a local variable for faster look up, but available to the entire script. --[[function findPlayer(name) --This function is not used in this script whatsoever. I have no idea why it's here. for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end--]] function onChatted(message) if message:sub(1, 10) == "!outscore " and isAdmin[player.Name] then --if an admin chats !outscore block = (message:sub(11)) --get the number after the message end end function onHumanoidDied(humanoid, player) local stats = player:findFirstChild("leaderstats") if stats then --this is a simplified way to check if something exists. If it's nil, it'll return false and not run the code local deaths = stats:findFirstChild("Wipeouts") deaths.Value = deaths.Value + 1 if deaths.Value > block then --this is only needed once. player.TeamColor=BrickColor.new("White") --a = game.Players:GetChildren() --"a" isn't used anywhere pack=game.StarterPack:GetChildren() if #pack>0 then for i=1,#pack do pack[i]:destroy() --don't forget that this is the StarterPack for all players, not just the one who met the criteria. Also, you might want to make sure the character doesn't respawn until you change the StarterPack if that's what you really want to do. end end end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) onChatted(msg) end) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() print(player.Name .. " has died!") onHumanoidDied(character.Humanoid, player) end) end) end)
This code has not been tested.
local isAdmin = {["Incrility"] = true} local block --make block a local variable for faster look up, but available to the entire script. function onChatted(message) if message:sub(1, 10) == "!outscore " and isAdmin[player.Name] then --if an admin chats !outscore block = (message:sub(11)) --get the number after the message end end function onHumanoidDied(humanoid, player) local stats = player:findFirstChild("leaderstats") if stats then --this is a simplified way to check if something exists. If it's nil, it'll return false and not run the code local deaths = stats:findFirstChild("Wipeouts") deaths.Value = deaths.Value + 1 if deaths.Value >= block then --this is only needed once. player.TeamColor=BrickColor.new("White") --a = game.Players:GetChildren() --"a" isn't used anywhere pack=game.StarterPack:GetChildren() if #pack>0 then for i=1,#pack do pack[i]:destroy() --don't forget that this is the StarterPack for all players, not just the one who met the criteria. Also, you might want to make sure the character doesn't respawn until you change the StarterPack if that's what you really want to do. end end end end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) onChatted(msg) end) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() print(player.Name .. " has died!") onHumanoidDied(character.Humanoid, player) end) end) end)
I recopied it i think i might have changed something dont really know but the script does not work... I do appreciate the answer though. I got no error in output and when i played game and executed it didnt work.