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: What's wrong with this

Previous Thread :: Next Thread 
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
27 May 2014 09:33 PM
ds = game:GetService("DataStoreService"):GetDataStore(stats)
ammounts = {}
game.Players.PlayerAdded:connect(function(player)
if ds:GetAsync(player.userId) then
return
elseif not ds:GetAsync(player.userId) and player.userId ~= game.CreatorId then
ds:SetAsync(player.userId,ammounts[#ammounts+1] == 0)
elseif not ds:GetAsync(player.userId) and player.userId == game.CreatorId then
ds:SetAsync(player.userId,ammounts[#ammounts+1] == 100000)
end
game.Part.TextLabel = "Player "..player.userId.." with "..ds:GetAsync(player.userId)
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
27 May 2014 09:35 PM
A. What's the problem?
B. Use UpdateAsync
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
27 May 2014 09:35 PM
The return, add an end after it
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
27 May 2014 09:37 PM
@te
I have elseifs
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
27 May 2014 09:37 PM
make sure you use edit mode to test datastores, if you accessed it from a file on your pc it wont work... I almost messed up my script because I forgot that XD
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
27 May 2014 09:38 PM
Lol forgot surfacegui.TextLabel
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
27 May 2014 09:40 PM
Still doesn't work
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
27 May 2014 09:41 PM
:GetDataStore(stats)


Make "stats" a string...
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
27 May 2014 09:44 PM
Forgot .Text
Simple brain mistakes
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
27 May 2014 09:48 PM
Still doesn't work
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
28 May 2014 05:39 AM
elseif is not an end.

and stats on line one should be a string
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
28 May 2014 07:05 AM
@Te
Go back to school and learn about elseifs. K?
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
29 May 2014 09:51 AM
elseif ~= end

Sure, it has an E, but it's missing an N and a D
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
29 May 2014 10:14 AM
Te is right xD how can you say that elseif is an end? Ok i see you are new to roblox (except if this is an alt) and you may get simple problems.
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
29 May 2014 10:22 AM
No I mean if you can't do this:

if a == a then
return true
end
elseif a == b then
return b
end


That's what te is telling me to do.
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
29 May 2014 10:48 AM
if x then
print("x")
elseif not x then
print("no x")
end

Seriously gtfo icy
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
29 May 2014 03:13 PM
can't because you can't return elseifs. This is what concept he has in his code

function stuff(target)
if target.Name == "Trioxide" or target.Name == "EverythingScripted" then
return -- NEEDS AN END HERE.
elseif target.Name ~= "Trioxide" or target.Name == "EverythingScripted" then
print("This guy knows how to use returns")
end
end
Report Abuse
EverythingScripted is not online. EverythingScripted
Joined: 13 May 2014
Total Posts: 4378
29 May 2014 03:21 PM
@Teh
If your right, then explain why your code shows up as a red line and mine doesn't?
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
29 May 2014 03:34 PM
Well, now I see. I thought returns needed their own end, because when I was studying them they were always used at the end

function stuff(target)
if target.Name == "TehIcyStar" then return end
if target.Name == "EverythingScripted" then
print("sorry for being ignorant")
end
end
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
29 May 2014 03:37 PM
oh, Your script, you forgot the key, I believe

ds:SetAsync(key,newValue)
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
29 May 2014 06:02 PM
any idea which part isn't working? loading/saving? wait they depened on each other, nvm lolz.

so the script is run perfectly through, no errors? if you put a print function after each line it would print everything

if so then I think I know what needs to be fixed

first, I have never seen anything like ammounts[#ammounts + 1] == 100000 before, so i am assuming you researched to get something like that

but when you say ammounts = {}
it appears that you are trying to load the value saved into a table

I did this too for my data store script and i was freaking out because it wasn't loading the saved values, but i forgot one line that changes everything.....

so you want the 1 saved value to be put into the table ammounts right?

you have to say:

local ammounts = {}
amounts = ds:GetAsync(player.userId)


this puts the value you saved into a table

also it seems like you are trying to save a table with: ammounts[#ammounts + 1]

if you are creating a table you need to use {} not []
you use [] for things like...

local ammounts = {}
amounts = ds:GetAsync(player.userId)
x = stats[1] -- specifically [] not {}
print(x) -- value saved
--this loads the value, puts it into a table, sets a variabke (could be an int value,string value, text etc) = to the value loaded, and prints that value
so... if you are trying to use tables, try this and make sure you save the table with {} enclosing the value to be saved not [] :)

resources to help you:
http://wiki.roblox.com/index.php/Table roblox wiki tables

http://pastebin.com/SeHCQySr another persons scrip that help me find out about loading values into tables (see lines 15,16,30,31,49 from the pastebin)

Please replay back with errors/success/ what ever happens from this =x I hope this helped get you onto the right track.
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
30 May 2014 04:26 AM
ICY, LEARN TO SCRIPT BEFORE YOU START LYING ABOUT STUFF YOU DO NOT KNOW. YOU DO NOT KNOW HOW RETURN WORKS SO DO NOT TRY TO TELL PEOPLE HOW RETURN WORKS.

x = function(y)
if y == 1 then
return y
elseif y == 2 then
return y^2
end
end

print(x(1)) --> 1
print(x(2)) --> 4
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
30 May 2014 09:32 AM
No need to yell. I apologized, and that's enough.
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
30 May 2014 02:34 PM
how do returns work anyways? brings you to a dif part of the script?
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
30 May 2014 07:30 PM
function AddFive(num)
return num+5
end

count = 1

while true do
print(AddFive(count))
count = count+1
wait(1)
end

>6
>7
>8
>9
>10
and so on

Google search for returns, it's an important skill to learn -_-'
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