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: Data Store help please!

Previous Thread :: Next Thread 
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 02:25 PM
game.Players.PlayerAdded:connect(function(player)
datastore = game:GetService("DataStoreService"):GetDataStore("Points")
local key = "user_" .. player.userId
datastore:GetAsync(key)
if key == nil then
datastore:UpdateAsync(key, function(oldVal)
local newval = oldval or 0
newval = newval + 50
return newval
end)
end
end)

I have yet to find my problem :c.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Apr 2014 02:39 PM
Take out lines 4 and 5
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 02:43 PM
game.Players.PlayerAdded:connect(function(player)
datastore = game:GetService("DataStoreService"):GetDataStore("Points")
local key = "user_" .. player.userId
datastore:UpdateAsync(key, function(oldVal)
local newval = oldval or 0
newval = newval + 50
return newval
end)
end)
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 02:45 PM
still not working :c, i even tried it in play mode.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Apr 2014 03:01 PM
How do you know it is not working?
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 03:04 PM
its supposed to update the value "Points" in the players leaderstats(Model)..

players
-player1
--'leaderstats'
---'Points'

but I dont think i did it right did I ?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Apr 2014 03:04 PM
game.Players.PlayerAdded:connect(function(player)
local l = Instance.new("Model", player)
l.Name = "leaderstats"
local p = Instance.new("IntValue", l)
p.Name = "Points"
datastore = game:GetService("DataStoreService"):GetDataStore("Points")
local key = "user_" .. player.userId
datastore:UpdateAsync(key, function(oldVal)
local newval = oldval or 0
newval = newval + 50
return newval
p.Value = newval
end)
end)



Would it work?
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 03:07 PM
I already made the leaderboard script, should I incorporate that into the same script though just to try?
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 03:12 PM
game.Players.PlayerAdded:connect(function(player)
local l = Instance.new("Model", player)
l.Name = "leaderstats"
local p = Instance.new("IntValue", l)
p.Name = "Points"
datastore = game:GetService("DataStoreService"):GetDataStore("Points")
local key = "user_" .. player.userId
datastore:UpdateAsync(key, function(oldVal)
local newval = oldval or 0
newval = newval + 50
return newval
p.Value = newval
end)
end)

16:08:48.024 - Workspace.Script:14: 'end' expected (to close 'function' at line 10) near 'p'

Also, i think it has to do with the line after return because whenever I removed 'p.Value' it doesnt error
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 03:25 PM
Still doesn't work :c
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 03:39 PM
m
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Apr 2014 04:44 PM
That script should work...
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 05:12 PM
it keeps saying that error i posted..

Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 05:22 PM
maybe I didn't make myself clear

basically this script is to award 50 points to the newly entered player, EVERYTIME.

So if someone joins in, he will get 50 points. If that same person joins again, he gets another 50 points and so on..
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Apr 2014 05:24 PM
Try adding an end. I don't see why there should be one. But the error says to...
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 05:34 PM
game.Players.PlayerAdded:connect(function(player)
local l = Instance.new("Model", player)
l.Name = "leaderstats"
local p = Instance.new("IntValue", l)
p.Name = "Points"
datastore = game:GetService("DataStoreService"):GetDataStore("Points")
local key = "user_" .. player.userId
datastore:UpdateAsync(key, function(oldVal)
local newval = oldval or 0
newval = newval + 50
p.Value = newval
return newval
end)
end)

I used this and it worked but only once and it doesn't work again.

game.Players.PlayerAdded:connect(function(player)
local l = Instance.new("Model", player)
l.Name = "leaderstats"
local p = Instance.new("IntValue", l)
p.Name = "Points"
datastore = game:GetService("DataStoreService"):GetDataStore("Points")
local key = "user_" .. player.userId
datastore:UpdateAsync(key, function(oldVal)
local newval = oldval or 0
newval = newval + 50
return newval
end)
p.Value = newval
end)

This doesnt work at all.

Adding an extra end doesn't work either. Im getting annoyed :/.

Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
03 Apr 2014 05:50 PM
sigh please..
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