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: Wow...

Previous Thread :: Next Thread 
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
12 Jul 2014 10:59 AM
Hey, I was just wondering why this wouldn't work...



[This bit goes into a Script which is then placed in Workspace]


'DS = game:GetService("DataStoreService"):GetDataStore("Spawns")
SModel = Workspace.Spawns --Spawns

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
local D = DS:GetAsync(p.userId)
if D == nil then
DS:SetAsync(p.userId, 1)
end
local D = DS:GetAsync(p.userId)
c:MoveTo(SModel:FindFirstChild(D))
end)
end)'



[This goes into a Script in each SpawnLocations, each labeled 1, 2, 3, 4, etc... In the Model 'Spawns']



'DS = game:GetService("DataStoreService"):GetDataStore("Spawns")

script.Parent.Touched:connect(function(h)
local plr = game.Players:GetPlayerFromCharacter(h.Parent)
if plr then
DS:SetAsync(plr.userId, tonumber(script.Parent.Name))
end
end)'

-------------------------------------------------------------------------------

I've ran the Top Script and it seems to work fine with no error's in the Output box.
But when I run the second script that's in one of the SpawnLocations, (for example I'll run the script in Spawn '2') and I'll get this Error in Output:


'-DS = game:GetService("DataStoreService"):GetDataStore("Spaw:3: attempt to index global 'script' (a nil value)
-Stack Begin
- Script 'DS = game:GetService("DataStoreService"):GetDataStore("Spaw', Line 3
- Stack End'

Obviously you can't really get an accurate error message seeing as it would only work once touched... But I just need to know why it wont work when I play the game, go to the second spawn, touch it, leave the game, rejoin the game but find that I've started on the original first spawn...

(I'm basically going for a checkpoint system in my RPG)

Thanks in advance
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
12 Jul 2014 11:01 AM
'script' isn't defined in the command bar.
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
12 Jul 2014 11:12 AM
Workspace.Spawns.2.ScriptForTouch:6: attempt to index global 'DS' (a nil value)
Stack Begin
Script 'Workspace.Spawns.2.ScriptForTouch', Line 6
Stack End
Disconnected event because of exception
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
12 Jul 2014 11:13 AM
There's a "'" before "DS"
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
12 Jul 2014 01:02 PM
I put a quotation mark before the DS and at the end) to make sure you can see that they aren't all one big script...

+ Bump
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
12 Jul 2014 01:21 PM
Bumppp
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
12 Jul 2014 01:25 PM
Bump -.-
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
12 Jul 2014 01:28 PM
Everyone is SO helpful here today... -.-
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
12 Jul 2014 02:58 PM
Yea, they're aren't actually great at helping sometimes.

Try this;

DS = game:GetService("DataStoreService"):GetDataStore("Spawns")
Brick = script.Parent

Brick.Touched:connect(function(h)
local plr = game.Players:GetPlayerFromCharacter(h.Parent)
if plr then
DS:SetAsync(plr.userId, tonumber(Brick.Name))
end
end)



I don't see why it would work but give it a try. Maybe someone here'll have a better answer :P
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
13 Jul 2014 05:15 AM
I get this:

- Workspace.Spawns.2.ScriptForTouch:7: attempt to index global 'DS' (a nil value)
- Stack Begin
- Script 'Workspace.Spawns.2.ScriptForTouch', Line 7
- Stack End
- Disconnected event because of exception
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
13 Jul 2014 05:28 AM
That means DS wasn't set to the DataStore on line 1...

But we clearly set it -_-
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
13 Jul 2014 06:29 AM
Exactly :/ What could be wrong? :(
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
13 Jul 2014 07:34 AM
Bumpppppp
Report Abuse
123happy is not online. 123happy
Joined: 23 Sep 2008
Total Posts: 23
14 Jul 2014 07:57 AM
Bumpp
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
14 Jul 2014 08:18 AM
Try this, I doubt it'll work but at least I'm trying (unlike others)

local DS = game:GetService("DataStoreService"):GetDataStore("Spawns")
local Brick = script.Parent

Brick.Touched:connect(function(h)
local plr = game.Players:GetPlayerFromCharacter(h.Parent)
if plr then
DS:SetAsync(plr.userId, tonumber(Brick.Name))
end
end)
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