|
| 15 Jan 2015 07:41 PM |
local ds = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(plr) local l = Instance.new("IntValue", plr) l.Name = "leaderstats" local lvl = Instance.new("IntValue",l) lvl.Name = "Level" local key = tostring(plr.userId).."_level" local data = ds:GetAsync(key) or 0 lvl.Value = data workspace.LevelTPer.Touched:wait() return data.Value + 1 lvl.Value = data.Value -- ERROR HERE end end)
game.Players.PlayerRemoving:connect(function(plr) local key = tostring(plr.userId).."_level" local current = plr.leaderstats.Level local data = ds:GetAsync(key) if data then ds:UpdateAsync(key,function(old) return current.Value; end) else ds:SetAsync(key,current.Value) end end)
what is wrong... also it says expected 'end' near 'function' in line 3, got 'lvl'
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Jan 2015 07:46 PM |
function example() return 1 lol = 5 end
example() print(lol)
>> nil
The function ends at the return.
while wait() do break lol = 5 end print(lol)
>> nil
The while loop ends at break. |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 07:47 PM |
replace the first part with this
game.Players.PlayerAdded:connect(function(plr) local l = Instance.new("IntValue", plr) l.Name = "leaderstats" local lvl = Instance.new("IntValue",l) lvl.Name = "Level" local key = tostring(plr.userId).."_level" local data = ds:GetAsync(key) or 0 lvl.Value = data workspace.LevelTPer.Touched:wait() return data.Value + 1 lvl.Value = data.Value end) |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 08:58 PM |
ok thx
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 09:01 PM |
@KOT No, still same problem..
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 15 Jan 2015 09:04 PM |
lvl.Value = data.Value -- ERROR HERE end end)
You have an extra end. |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 09:04 PM |
k, fixed; replace first part with this
local ds = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(plr) local l = Instance.new("IntValue", plr) l.Name = "leaderstats" local lvl = Instance.new("IntValue",l) lvl.Name = "Level" local key = tostring(plr.userId).."_level" local data = ds:GetAsync(key) or 0 lvl.Value = data workspace.LevelTPer.Touched:wait() data.Value = data.Value + 1 lvl.Value = data.Value -- ERROR HERE end)
|
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 09:05 PM |
thank you
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 15 Jan 2015 09:07 PM |
This wouldn't be to hard to locate and fix if you tabbed your scripts in the traditional ROBLOX way.
function cat() (tab)return 6 end
if cat == 6 then (tab)print("I like cats") end |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 09:31 PM |
the biggest problem was this:
"return data.Value + 1 lvl.Value = data.Value -- ERROR HERE"
notice the return lol |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 15 Jan 2015 10:01 PM |
@cody
'function example() return 1 lol = 5 end '
Actually that would error |
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 15 Jan 2015 10:08 PM |
| @128GB No, it wouldn't. Are you thinking of a different language perhaps? |
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 15 Jan 2015 10:09 PM |
| Oh, I see that it does now. That's strange. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 15 Jan 2015 10:24 PM |
You can't do anything after returning besides ending something (Like an if statement)
(At least that I know of there is nothing else you can do) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 15 Jan 2015 10:25 PM |
And I mean directly after, if you end a statement you can keep doing other stuff
Like
function a() if (false) then return nil; end return 1; end
print(a()) -->1
(I did if false because if I did true it would have returned nil and ended) |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 11:28 PM |
so i cant use return???
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 11:38 PM |
bump bump bump
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 11:48 PM |
print(1*10^2*90+1 .."th bump")
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2015 11:56 PM |
PLEASE READ THIS
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Jan 2015 03:02 AM |
cody you are using global vars as well, meaning they would be defined outside.
OP you have an extra end for some reason, remove the "end" BEFORE the "end)" and put the return statement after the lvl.Value = lbah |
|
|
| Report Abuse |
|
|