• Register a free account to view all forum content. Click here to create your own account.

Need Some Help

Joined
Aug 29, 2018
Messages
67
Ratings
5
Roblox
GamingMaster0124
Discord
GamingMaster YT#7834
Im making an obby because im really bad at scripting and im not sure if this is possible with how im doing it but im using teams as checkpoints.

So each team has a color and a spawnpoint and when you make it across the level you step on the spawnpoint and that makes you that team whitch would be called level whatever and right now it does not save your level(or team because thats what it actually is) and i was wondering if there is a way to make that save and if someone could help me make it save with just like a script or something.

so im not really sure if that is possible with the way i have it set up but if it is and someone could help me out that would be awsome

also i could pay a little if needed but i do not have much robux so i would not be able to pay very much if you do need pay
 

CallMeKY

Active Member
Joined
Feb 25, 2018
Messages
387
Ratings
115
Roblox
CallMeKY
Discord
CallMeKY#5012
If you're making a large obby, it would make more sense to me to use an IntValue to record where they are. With that you could do checkpoints with something like this.
Code:
if CurrentCheckpoint.Value >= CheckpointID.Value then
    print(Player.Name .. ' already passed checkpoint ' .. CheckpointID.Value)
elseif CurrentCheckpoint.Value < CheckpointID.Value - 1 then
    print(Player.Name .. ' has not yet reached checkpoint ' .. CheckpointID.Value)
else
    CurrentCheckpoint.Value = CheckpointID.Value
    print(Player.Name .. ' has reached checkpoint ' .. CheckpointID.Value)
end
As for saving, I'd check out Data Stores. If you don't want to make it from scratch, DataStore2 seems to be fairly well received and has in-depth tutorials.
 
Joined
Aug 29, 2018
Messages
67
Ratings
5
Roblox
GamingMaster0124
Discord
GamingMaster YT#7834
If you're making a large obby, it would make more sense to me to use an IntValue to record where they are. With that you could do checkpoints with something like this.
Code:
if CurrentCheckpoint.Value >= CheckpointID.Value then
    print(Player.Name .. ' already passed checkpoint ' .. CheckpointID.Value)
elseif CurrentCheckpoint.Value < CheckpointID.Value - 1 then
    print(Player.Name .. ' has not yet reached checkpoint ' .. CheckpointID.Value)
else
    CurrentCheckpoint.Value = CheckpointID.Value
    print(Player.Name .. ' has reached checkpoint ' .. CheckpointID.Value)
end
As for saving, I'd check out Data Stores. If you don't want to make it from scratch, DataStore2 seems to be fairly well received and has in-depth tutorials.
for this script do i just put it into a block, or do i put it into the spawn point. Also for this script does that display what level they are on? because the way I have it set up it does just not very well because there are alot of diffrent colors. But even if not i would rather have a script for the checkpoint because I can only have so many colors before i have to go to coustom colors and that would not be fun.

Sorry for all the questions i am really bad at scripting
 
Joined
Jan 14, 2019
Messages
10
Ratings
1
Roblox
Fractaloid
QUOTE:
for this script do i just put it into a block, or do i put it into the spawn point. Also for this script does that display what level they are on? because the way I have it set up it does just not very well because there are alot of diffrent colors. But even if not i would rather have a script for the checkpoint because I can only have so many colors before i have to go to coustom colors and that would not be fun.
No, what you ought to do is remove teams and team spawns entirely, and make a checkpoint system that utilizes IntValues instead. Setting the system up is easy, though I'd probably use ObjectValues in addition to IntValues.

First thing you ought to do is set up the spawn template. Note that these aren't actually spawn locations - they're just parts that contain an IntValue. The IntValue for your first spawn point should be 1; it's just to facilitate the table, so you don't have to put the script into every spawn point.

EDIT: Next, you add an IntValue and an ObjectValue into StarterPlayer. I use "activespawn" and "checkpointnumber" later, for ObjectValue and IntValue respectively. The ObjectValue isn't strictly necessary, but it's an easy shortcut.

Once you have a couple pseudo-spawnpoints set up, you can table them like so:

Code:
name = "Checkpoint" --name of the IntVal in each spawn location
local spawns = {} --empty table to write with spawn locations - used later

for i,v in pairs(game.Workspace:GetChildren()) do
    if v:FindFirstChild(name) then
        table.insert(v,v[name].Value) --tables spawns in sequential order; not necessary, but maybe helpful
    end
end
In laymenspeak, you're telling the game to, for every direct descendant of "game.Workspace", see if it has a direct descendant with the name held by "name" - in this case, Checkpoint. If found, insert the direct descendant of "game.Workspace" into table "spawns". Know that what's being stored in the table is a reference to the part itself: this allows you to do this...

Code:
for _,v in pairs(spawns) do

if v.Touched:connect(function(part) --indentations broke, sorry if it triggers you. :Y

if part.Parent:IsA("Model") and game.Players:GetPlayerFromCharacter(part.Parent)~=nil then --test to see if part belongs to a character

local char = part.Parent
local pl = game.Players:GetPlayerFromCharacter(char)
local activespawn = pl:FindFirstChild("activespawn",1) --Objectvalue; for pseudo-respawn
local checkpointnumber = pl:FindFirstChild("checkpointnumber",1) --IntValue; data persistence (referencing "spawns" to get correct "v" for activespawn)

if activespawn.Value ~= v and checkpointnumber.Value < v[name].Value then -- Active spawn isn't v, and v has higher cp#
activespawn.Value = v
checkpointnumber.Value = v[name].Value
else --I could keep going, but I'm too lazy, and this is a pretty big bone already :P
--[[code stuff]]

end

end)

end
This could be slightly off base, but this function should run whenever any of the spawnpoints ("v", from earlier) is touched by any kind of part. The script checks to see if the part belongs to a model (all characters are models by default), and if that model is the character for any players currently in-game. If yes to both, it searches recursively for "activespawn", an ObjectValue that will serve as a reference to your active spawn - the part itself, not any of its properties - and "checkpointnumber", an IntValue that's used here for data persistence and as a check to see whether the touched spawn is next, first, or wherever.

An added bonus of this system is that you don't actually need to kill the player to make them respawn. If you're using an ObjectValue in addition to an IntValue, you can just teleport the player back to the position of "activespawn.Value". Else, you can index the table using the IntValue stored in the player, using "spawns[checkpointnumber.Value]", to pull the correct spawn to teleport the player back to.

Just know that this long, rambling mess is probably a little outdated, since I haven't really been programming in Roblox much since 2017-ish.