Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 09:57 AM |
Im making a simple obby, but i just have no idea how to make the stages save for the player.
If they get up to stage 40 or something and then lose connection, they will dislike the place.
I need a script and info on where to put the script, thats pretty much the only problem I have.
If anyone could help, I would really appreciate any answers! |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:00 AM |
Use DataStore to store a value every checkpoint.
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 10:02 AM |
I know about datastore, but how do i make the script
I literally have no idea what to make or write |
|
|
| Report Abuse |
|
|
AIicks
|
  |
| Joined: 10 Apr 2012 |
| Total Posts: 788 |
|
|
| 07 Jul 2017 10:05 AM |
Name the spawn points 1-whatever
local currentPlayerStage = {}
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) wait(3) for _, v in pairs(char:GetChildren()) do if v:IsA("BasePart") then v.Touched:Connect(function(hit) if hit:IsA("SpawnLocation") then --CHECKS IF THEY'VE TOUCHED A SPAWN LOCATION, change if the spawn points aren't spawn locations lol. if tonumber(hit.Name) == currentPlayerStage[plr] or not currentPlayerStage[plr] then currentPlayerStage[plr] = tonumber(hit.Name) end end end) end end end) end)
game.Players.PlayerRemoving:Connect(function(plr) currentPlayerStage[plr] = nil --just tidies everything up as the server gets older end) |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:07 AM |
local DSService = game:GetService('DataStoreService'):GetDataStore('PUT SOME RANDOM KEY HERE')
game.Players.PlayerAdded:connect(function(player) local uniquekey = ('id' .. player.userId) local stage = Instance.new('IntValue', player) stage.Name = 'stage' local GetSaved = DSService:GetAsync(uniquekey) if GetSaved then stage.Value = GetSaved[1] else local NumbersForSaving = {stage.Value} DSService:SetAsync(uniquekey, NumbersForSaving) end end)
game.Players.PlayerRemoving:connect(function(player) local uniquekey = ('id' .. player.userId) local Savetable = {player.stage.Value} DSService:SetAsync(uniquekey, Savetable) end)
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:07 AM |
Make every checkpoint it sets the value named "stage" inside the player.
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 10:08 AM |
Thank you so much for the script, looking at it really made sense!
Now all i need to know is where to I place this script into?
|
|
|
| Report Abuse |
|
|
AIicks
|
  |
| Joined: 10 Apr 2012 |
| Total Posts: 788 |
|
|
| 07 Jul 2017 10:08 AM |
o if they disconnect, misread. Use datastores.
local dsService = game:GetService("DataStoreService") local playerLevelData = dsService:GetDataStore("PlayerLevelData")--name of datastore for player level data
game.Players.PlayerRemoving:Connect(function(plr) playerLevelData:SetAsync(plr.UserId, plr.leaderstats.Level.Value) end)
game.Players.PlayerAdded:Connect(function(plr) repeat wait() until plr:FindFirstChild("leaderstats") repeat wait() until plr:FindFirstChild("leaderstats"):FindFirstChild("Level") plr.leaderstats.level = playerLevelData:GetAsync(plr.UserId) end) |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:10 AM |
Place it into a server script inside the ServerScriptSerivce.
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 10:25 AM |
Where do i find this 'Server Script'?
Theres only Folder, Module Script and Script.
Sorry, Ive never used anything like this before, completely new to it |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:26 AM |
Server script is a type of script, studio just straight up calls it "Script".
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 10:29 AM |
Oh I see, Ive inserted this script into the 'Script' thing
local DSService = game:GetService('DataStoreService'):GetDataStore('PUT SOME RANDOM KEY HERE')
game.Players.PlayerAdded:connect(function(player) local uniquekey = ('id' .. player.userId) local stage = Instance.new('IntValue', player) stage.Name = 'stage' local GetSaved = DSService:GetAsync(uniquekey) if GetSaved then stage.Value = GetSaved[1] else local NumbersForSaving = {stage.Value} DSService:SetAsync(uniquekey, NumbersForSaving) end end)
game.Players.PlayerRemoving:connect(function(player) local uniquekey = ('id' .. player.userId) local Savetable = {player.stage.Value} DSService:SetAsync(uniquekey, Savetable) end)
I change the put some random key to 'Checkpoint'
And where it says stage.name = 'stage' I changed it to 'Checkpoint' since every check point i have placed down is named 'Checkpoint' in the workspace?
Did I do it right? I suppose not because nothing worked, Ive read the script a few times but still dont see the problem.
Anyway to add you on discord and show you my screen? |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:34 AM |
Make the random key something random, that is how you can access your DataStore, so if someone else has it they can also access the DataStore. And there is nothing in the workspace. There is a value in the player named stage unless you changed it to .Name = 'Checkpoint', and that is a number value. You still need to make checkpoints set the value but I did the DataStore for you.
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 10:43 AM |
Im extremely sorry, But I just dont understand this, I havent covered the full basics of rbx lua yet.
If you possibly could, may you please take a copy of my game and do everything in there?
Once you are done I will read everything a couple of times to understand what you did there, so that you didnt just do everything I dont understand at all.
I can pay 30 robux right now, from my primary as robux is currently very limited to me with no builders club.
Please reply with a yes if you can do this, I will uncopylock the game |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 10:44 AM |
Ik that script is from AlvinBlox.
Most of his scripts don't work |
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Jul 2017 10:48 AM |
Works just fine lel, I have been using it since I learned. Also, I can make the place later.
for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 10:49 AM |
This vid I made teaches u to save one value with one datastore.
https://www.youtube.com/watch?v=2NPqKR9D2gQ
And this vid I made teachs u to save multiple values with one datastore.
https://www.youtube.com/watch?v=zY53itnBchE
Sub to my channel for more scripting vids :3 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 11:02 AM |
| thanks i will watch them now and will sub |
|
|
| Report Abuse |
|
|
Baqh
|
  |
| Joined: 19 Jul 2016 |
| Total Posts: 7973 |
|
|
| 07 Jul 2017 11:07 AM |
Again, i would need everything explained, seeing a code being written doesn't provide much help, however, would you mind configuring my game so that checkpoints save?
pretty please?
I subbed :) |
|
|
| Report Abuse |
|
|