generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Cookie Player Points after each round?

Previous Thread :: Next Thread 
zacster129 is not online. zacster129
Joined: 21 Nov 2011
Total Posts: 92
26 Aug 2014 08:05 PM
Every round, if you win, I want it to give you, the number of health left on the cookie divided by five, points. it keeps saying:

Workspace.Countdown:61: attempt to index field 'leaderstats' (a nil value)

:(
-------------------------------------
-------------------------------------
CODE: (Countdown script)
-------------------------------------
-------------------------------------
local M = game.Workspace.Hint
local CMs = game.Lighting.CMs
CMCs = CMs:clone()
MCH = game.Workspace["Magic Cookie"]


while wait() do
M.Text = "Intermission..."
wait(1)
M.Text = "A Huge Wave Of Cookie Monsters Is About To Arrive!"
wait(5)
M.Text = "10"
wait(1)
M.Text = "9"
wait(1)
M.Text = "8"
wait(1)
M.Text = "7"
wait(1)
M.Text = "6"
wait(1)
M.Text = "5"
wait(1)
M.Text = "4"
wait(1)
M.Text = "3!"
wait(1)
M.Text = "2!"
wait(1)
M.Text = "1!!"
wait(1)
M.Text = "A HUGE WAVE OF COOKIE MONSTERS HAS ARRIVED!!"
wait(2)
M.Text = "PROTECT THE MAGIC COOKIE!!"
wait(2)
M.Text = " "
CMCs = CMs:clone()
CMCs.Parent = Workspace

for i = 0,1 do
wait(1)
MCH2 = MCH.Humanoid.Health

if MCH2 <= 0 then
CMCs:remove()
M.Text = "The Cookie Has Been Destroyed... :("
wait(2)
M.Text = "No Points Have Been Granted."
wait(2)
break
end
end

if MCH2 > 0 then
CMCs:remove()
M.Text = "The Wave Has Ended."
wait(3)
M.Text = (tostring(MCH2/5).." Cookie Power Point(s) Are Granted to Everyone!")
wait(2)
local p = game.Players:GetPlayers()
local s = p.leaderstats.CCP
s=s+MCH2/5
end
MCH.Humanoid.Health = 1000
end
-------------------------------------
-------------------------------------
CODE: (Zombie script)
-------------------------------------
-------------------------------------
function Entered(player)
wait()
if player:findFirstChild("leaderstats") ~= nil then
player.leaderstats:remove()
end

stats = Instance.new("IntValue")
stats.Parent = player
stats.Name = "leaderstats"

money = Instance.new("IntValue")
money.Parent = stats
money.Name = "CPP"
money.Value = 9000

end

game.Players.PlayerAdded:connect(Entered)

c = game.Players:GetChildren()
for i=1, #c do
Entered(c[i])
end

-------------------------------------
-------------------------------------
CODE: (Coins Script)
-------------------------------------
-------------------------------------
function onDied()
for i =1,script.CoinCount.Value do
local coin = Instance.new("Part")
coin.Parent = game.Workspace
coin.Position = script.Parent.Parent.Torso.Position + Vector3.new(math.random(-3,3),math.random(-3,3),math.random(-3,3))
coin.Shape = 1
coin.formFactor = "Plate"
coin.Name = "Coin"
coin.BrickColor = BrickColor.new(24)
coin.Reflectance = 0.5
coin.Size = Vector3.new(1,0.4,1)

local mesh = Instance.new("SpecialMesh")
mesh.Parent = coin
mesh.MeshId = "http://www.roblox.com/asset/?id=20939848"
mesh.Scale = Vector3.new(0.5, 0.5, 0.5)
mesh.TextureId = "http://www.roblox.com/asset/?id=21456464"

local clone = script.IncreaseCoin:Clone()
clone.Disabled = false
clone.Parent = coin
end
end

script.Parent.Died:connect(onDied)
-------------------------------------
-------------------------------------
CODE: (Give points script)
-------------------------------------
-------------------------------------
amnt = math.random(1,4)
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("CPP")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end

script.Parent.Touched:connect(onTouched)

-------------------------------------
-------------------------------------
And the work space it this:
-------------------------------------
-------------------------------------
Workspace
-Countdown
-Zombie Script
-Hint
Lighting
-CMs
--Cookie Monster
---Humanoid
----Script (Coins Script)
-----CoinCount
-----IncreaceCoin (Give Points Script)
--Cookie Monster
--Cookie Monster
--Cookie Monster
--Cookie Monster
--Cookie Monster
--Cookie Monster
-------------------------------------
-------------------------------------


HEELLPP



Report Abuse
cingwar73 is not online. cingwar73
Joined: 16 Aug 2009
Total Posts: 358
26 Aug 2014 08:09 PM
You defined p as a table of the players, but didn't do anything to that table.

-------------------------------------
-------------------------------------
CODE: (Countdown script)
-------------------------------------
-------------------------------------
local M = game.Workspace.Hint
local CMs = game.Lighting.CMs
CMCs = CMs:clone()
MCH = game.Workspace["Magic Cookie"]


while wait() do
M.Text = "Intermission..."
wait(1)
M.Text = "A Huge Wave Of Cookie Monsters Is About To Arrive!"
wait(5)
M.Text = "10"
wait(1)
M.Text = "9"
wait(1)
M.Text = "8"
wait(1)
M.Text = "7"
wait(1)
M.Text = "6"
wait(1)
M.Text = "5"
wait(1)
M.Text = "4"
wait(1)
M.Text = "3!"
wait(1)
M.Text = "2!"
wait(1)
M.Text = "1!!"
wait(1)
M.Text = "A HUGE WAVE OF COOKIE MONSTERS HAS ARRIVED!!"
wait(2)
M.Text = "PROTECT THE MAGIC COOKIE!!"
wait(2)
M.Text = " "
CMCs = CMs:clone()
CMCs.Parent = Workspace

for i = 0,1 do
wait(1)
MCH2 = MCH.Humanoid.Health

if MCH2 <= 0 then
CMCs:remove()
M.Text = "The Cookie Has Been Destroyed... :("
wait(2)
M.Text = "No Points Have Been Granted."
wait(2)
break
end
end

if MCH2 > 0 then
CMCs:remove()
M.Text = "The Wave Has Ended."
wait(3)
M.Text = (tostring(MCH2/5).." Cookie Power Point(s) Are Granted to Everyone!")
wait(2)
for i,p in pairs(game.Players:GetChildren()) do -- Fix
--[[ Old code local = game.Players:GetChildren ]]--
local s = p.leaderstats.CCP
s=s+MCH2/5
end
end
MCH.Humanoid.Health = 1000
end
-------------------------------------
-------------------------------------
CODE: (Zombie script)
-------------------------------------
-------------------------------------
function Entered(player)
wait()
if player:findFirstChild("leaderstats") ~= nil then
player.leaderstats:remove()
end

stats = Instance.new("IntValue")
stats.Parent = player
stats.Name = "leaderstats"

money = Instance.new("IntValue")
money.Parent = stats
money.Name = "CPP"
money.Value = 9000

end

game.Players.PlayerAdded:connect(Entered)

c = game.Players:GetChildren()
for i=1, #c do
Entered(c[i])
end

-------------------------------------
-------------------------------------
CODE: (Coins Script)
-------------------------------------
-------------------------------------
function onDied()
for i =1,script.CoinCount.Value do
local coin = Instance.new("Part")
coin.Parent = game.Workspace
coin.Position = script.Parent.Parent.Torso.Position + Vector3.new(math.random(-3,3),math.random(-3,3),math.random(-3,3))
coin.Shape = 1
coin.formFactor = "Plate"
coin.Name = "Coin"
coin.BrickColor = BrickColor.new(24)
coin.Reflectance = 0.5
coin.Size = Vector3.new(1,0.4,1)

local mesh = Instance.new("SpecialMesh")
mesh.Parent = coin
mesh.MeshId = "http://www.roblox.com/asset/?id=20939848"
mesh.Scale = Vector3.new(0.5, 0.5, 0.5)
mesh.TextureId = "http://www.roblox.com/asset/?id=21456464"

local clone = script.IncreaseCoin:Clone()
clone.Disabled = false
clone.Parent = coin
end
end

script.Parent.Died:connect(onDied)
-------------------------------------
-------------------------------------
CODE: (Give points script)
-------------------------------------
-------------------------------------
amnt = math.random(1,4)
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("CPP")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end

script.Parent.Touched:connect(onTouched)

-------------------------------------
-------------------------------------
And the work space it this:
-------------------------------------
-------------------------------------
Workspace
-Countdown
-Zombie Script
-Hint
Lighting
-CMs
--Cookie Monster
---Humanoid
----Script (Coins Script)
-----CoinCount
-----IncreaceCoin (Give Points Script)
--Cookie Monster
--Cookie Monster
--Cookie Monster
--Cookie Monster
--Cookie Monster
--Cookie Monster
-------------------------------------
-------------------------------------
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
26 Aug 2014 08:11 PM
M.Text = "10"
wait(1)
M.Text = "9"
wait(1)
M.Text = "8"
wait(1)
M.Text = "7"
wait(1)
M.Text = "6"
wait(1)
M.Text = "5"
wait(1)
M.Text = "4"
wait(1)
M.Text = "3!"
wait(1)
M.Text = "2!"
wait(1)
M.Text = "1!!"
wait(1)



ew


for i = 10, 1, -1 do
M.Text = tostring(i) wait(1)
-- more code
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image