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 » Scripters
Home Search
 

Re: Why won't ROBLOX let me run 2 of the same scripts!

Previous Thread :: Next Thread 
chugmilk is not online. chugmilk
Joined: 28 May 2011
Total Posts: 5756
23 Jun 2015 06:03 PM
The second script will run but the first script returns "-" in game. The value doesn't change on the leaderstats, and I'm using DataStores for both scripts. All the difference is one creates adds "Cookie" intValue and one adds "Milk." Again the first script (Milk) script returns a "-" when the game runs...

Help the scripts are basically exactly the same!


--------
Script 1
--------
ds = game:GetService('DataStoreService'):GetDataStore('Stats')

game.Players.PlayerAdded:connect(function(plr)
local ls = Instance.new('Model',plr)
ls.Name = 'leaderstats'
local m = Instance.new('IntValue',ls)
m.Name = 'Milk'
local data = ds:GetAsync(plr.userId..'_data')
if data then
m.Value = data
else
m.Value = 0
end
end)

game.Players.PlayerRemoving:connect(function(plr)
local stat = plr.leaderstats.Milk
ds:SetAsync(plr.userId..'_data',stat.Value)
end)

while wait(1) do
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Milk.Value = Player.leaderstats.Milk.Value +1
end
end
end
--------
Script 2
--------
ds = game:GetService('DataStoreService'):GetDataStore('Stats')

as = game:GetService('DataStoreService'):GetDataStore('Stats')

game.Players.PlayerAdded:connect(function(plr)
local ls = Instance.new('Model',plr)
ls.Name = 'leaderstats'
local m = Instance.new('IntValue',ls)
m.Name = 'Cookies'
local data = as:GetAsync(plr.userId..'_data')
if data then
m.Value = data
else
m.Value = 0
end
end)

game.Players.PlayerRemoving:connect(function(plr)
local stat = plr.leaderstats.Cookies
as:SetAsync(plr.userId..'_data',stat.Value)
end)

while wait(1) do
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Cookies.Value = Player.leaderstats.Cookies.Value +1
end
end
end
Report Abuse
chugmilk is not online. chugmilk
Joined: 28 May 2011
Total Posts: 5756
23 Jun 2015 06:06 PM
Here is the output

18:04:58.155 - Milk is not a valid member of Model
18:04:58.156 - Script 'Workspace.Milk', Line 24
18:04:58.157 - Stack End

^^ Can't figure out why?
Report Abuse
chugmilk is not online. chugmilk
Joined: 28 May 2011
Total Posts: 5756
23 Jun 2015 06:27 PM
b1?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
23 Jun 2015 06:29 PM
Because milk isn't a valid member of the model. Fix your heiarchy
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
23 Jun 2015 06:29 PM
leaderstats:WaitForChild("Milk")
Report Abuse
chugmilk is not online. chugmilk
Joined: 28 May 2011
Total Posts: 5756
23 Jun 2015 06:32 PM
@Time it should be though since Milk and Cookies are the parent of leaderstats...
Report Abuse
chugmilk is not online. chugmilk
Joined: 28 May 2011
Total Posts: 5756
23 Jun 2015 06:33 PM
@Time it should be though since Milk and Cookies are both children of leaderstats...
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
23 Jun 2015 06:35 PM
You're creating 2 leaderstats. Put them into 1 script.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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