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: ugh, DataStoreService = confusing

Previous Thread :: Next Thread 
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:02 PM
no errors anywhere, but it doesn't work

--WHAT ITS SUPPOSED TO DO--
--[[
1. when u click "Send msg" in the "Friends list" it should set or update async or w/e into the "inbox" for islandmaker2012(or w/e the text in the box is)
and yes, the text is "islandmaker2012"

--Note: all variables are correct, so im not sure what im doing rong

when a player joins, it sees if inbox is empty, if its not, it creates a msg in their playergui with the text or unpack(inbox)
]]


--SEND SCRIPT--

send = script.Parent
msg = send.Parent
sendmsg = msg.Parent
to = sendmsg.Parent
p = script.Parent
repeat p=p.Parent until p:IsA("Player")
msgs = game:GetService("DataStoreService"):GetDataStore("Msgs")
inbox = msgs:GetAsync(to.Text.."Msgs") or {}
if inbox==nil or type(inbox~="table") then
inbox = {}
msgs:SetAsync(to.Text.."Msgs",inbox)
end
script.Parent.MouseButton1Click:connect(function()
print("Sending msg:"..msg.Text.." To:"..to.Text)
inbox[#inbox+1] = {from=p.Name,msg = msg.Text}
msgs:SetAsync(to.Text.."Msgs",inbox)
end)

--DISPLAY SCRIPT--

msgs = game:GetService("DataStoreService"):GetDataStore("Msgs")
game.Players.PlayerAdded:connect(function(p)
inbox = msgs:GetAsync(p.Name.."Msgs")
if inbox~=nil and type(inbox) == "table" then
m = Instance.new("Message",p:WaitForChild("PlayerGu"))
m.Text = unpack(inbox)
print(unpack(inbox))
game.Debris:AddItem(m,5)
else
msgs:SetAsync(p.Name.."Msgs",{})
end
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:15 PM
I guess no one knows how to fix..?
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
22 Jun 2014 12:17 PM
Any output?

I would appreciate it if you came to my place and donate some robux! Thanks!
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:18 PM
no output, no errors, im stumped :\
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jun 2014 12:19 PM
put prints between each line with the first line as 1, second as 2, etc, and see where it stops
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
22 Jun 2014 12:20 PM
You probably messed up on the conditions, most likely.

OHH waitt, I found it (not being sarcastic, I found it as I was typing .-.)

" m = Instance.new("Message",p:WaitForChild("PlayerGu")) -- PlayerGu? --> PlayerGui



I would appreciate it if you came to my place and donate some robux! Thanks!
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:21 PM
FKKKKKKKKKKKKKKKKKKKKKKKKKK


tyvm
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:22 PM
ok, now theres an error..

line 6, string expected

.-.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jun 2014 12:24 PM
m.Text = unpack(inbox)

what
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:25 PM
type(inbox) = "table"

k?

print(unpack({"Hi","Hello"}))

Hi Hello

.-.
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
22 Jun 2014 12:25 PM
It's a function that's called...


I would appreciate it if you came to my place and donate some robux! Thanks!
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:26 PM
I added "".. and ..""

to it but now it says:

Workspace.Script:6 attempt to concatenate a nil value..
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jun 2014 12:28 PM
Its because if inbox is empty, you will be trying to have something's text be nothing which isnt a string. If you try to concatenate to nothing, it will error.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jun 2014 12:29 PM
"".. and ..""

Also because youre using a term/variable that was never defined.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:31 PM
http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#unpack

unpack isn't undefined..

anyway

then should I add into the if statement..?

and #inbox~=0 then?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jun 2014 12:33 PM
Why dont you try?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:37 PM
now, it says this

Workspace.Script:6: attempt to concatenate a table value

WTF ROBLOX
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 12:38 PM
msgs = game:GetService("DataStoreService"):GetDataStore("Msgs")
game.Players.PlayerAdded:connect(function(p)
inbox = msgs:GetAsync(p.Name.."Msgs")
if inbox~=nil and type(inbox) == "table" and #inbox~=0 then
m = Instance.new("Message",p:WaitForChild("PlayerGui"))
m.Text = ""..unpack(inbox)..""--line 6
print(""..unpack(inbox).."")
game.Debris:AddItem(m,5)
elseif inbox==nil or type(inbox)~="table" then
msgs:SetAsync(p.Name.."Msgs",{})
end
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 01:25 PM
BUMP

I still haven't figured this out q.q
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 02:05 PM
Bump

im so lost q.q
Report Abuse
calebpwns1002 is not online. calebpwns1002
Joined: 29 Mar 2013
Total Posts: 521
22 Jun 2014 02:10 PM
wait does this show messages ingame? e.e
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 02:12 PM
^supposed to, but it doesn't, it just errors randomly
Report Abuse
calebpwns1002 is not online. calebpwns1002
Joined: 29 Mar 2013
Total Posts: 521
22 Jun 2014 02:22 PM
dont u need httpservice?
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