#I need help
121 messages · Page 1 of 1 (latest)
well I have a few scripts they might js need a few touch ups
Need more context
But basically, you can number the checkpoints manually and just :PivotTo() the character to workspace.Checkpoints[stage]
eaach checkpoint is labeled number according
1
2
3
since I only have 3 currently
im lowk new
I use
ai and tutorials
and my own brain knowledge
ill send u all the scripts im using
-- Script in each checkpoint part (e.g., Checkpoint1, Checkpoint2, ...)
local checkpointNumber = tonumber(script.Parent.Name:match("%d+")) -- Extract number from part name
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local stage = leaderstats:FindFirstChild("Stage")
if stage then
if stage.Value < checkpointNumber then
stage.Value = checkpointNumber
print(player.Name .. " reached stage " .. checkpointNumber)
else
print(player.Name .. " already passed this checkpoint")
end
else
print("Stage value not found in leaderstats for " .. player.Name)
end
else
print("Leaderstats not found for " .. player.Name)
end
else
print("Player not found for touched object")
end
end
end)
this is the script that i placed in all 3 checkpoints
-- Define initial spawn point
local initialSpawnPosition = game.Workspace.SpawnLocation -- Replace with your actual spawn point name
-- Function to respawn player at initial spawn point
local function respawnAtInitialSpawn(player)
local character = player.Character
if character then
character:Destroy()
end
local newCharacter = player.CharacterAdded:Wait()
newCharacter:SetPrimaryPartCFrame(initialSpawnPosition.CFrame)
end
-- Handle player join
game.Players.PlayerAdded:Connect(function(player)
-- Create leaderstats for player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create stage stat for player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Value = 1 -- Start at stage 1
stage.Parent = leaderstats
-- Respawn player at initial spawn
respawnAtInitialSpawn(player)
-- Handle respawn after death
player.CharacterAdded:Connect(function(character)
local lastCheckpoint = player:GetAttribute("LastCheckpoint")
if lastCheckpoint then
-- Teleport player to last checkpoint
local spawnPosition = game.Workspace:FindFirstChild("Checkpoint" .. lastCheckpoint)
if spawnPosition then
character:SetPrimaryPartCFrame(spawnPosition.CFrame)
else
warn("Last checkpoint not found for " .. player.Name)
-- Fallback to initial spawn if checkpoint not found
respawnAtInitialSpawn(player)
end
else
-- Fallback to initial spawn if no last checkpoint attribute
respawnAtInitialSpawn(player)
end
end)
end)
-- Handle player leaving
game.Players.PlayerRemoving:Connect(function(player)
-- Save last checkpoint to player attributes
local stage = player.leaderstats.Stage.Value
player:SetAttribute("LastCheckpoint", stage)
end)
this is the respawn script
-- Script in ServerScriptService or a LocalScript in a Player object
game.Players.PlayerAdded:Connect(function(player)
-- Create leaderstats folder
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create stage value
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Value = 1 -- Start at stage 1
stage.Parent = leaderstats
end)
this is the leaderstats script
everything works other than
I don't spawn on the checkpoints
is this AI-generated?
** You are now Level 1! **
mine didn't work
i was js sick of it
I've been doing this for 4 hours
like no joke
learn to script
only break i took was to shower n eat
im not reading all that
i could easily find the error
checkpoints are being searched for directly under workspace
with the name "CheckpointX" X being the checkpoint number
and checkpoints named "1, 2, 3"
workspace.Checkpoint1
workspace.Checkpoint2
etc
thats what the script is searching for
learn basic scripting, that way you wont need help on basic stuff like this.
short-term memory loss goin crazy rn fr
lmfao
im trying
js wanna also make a game
earn robux
and hire devs instead
I didn't spawn on checkpoint
I also have spawn locations
for when people first join the game
wont work
they spawn on those
why?
a million people have tried the same thing
you cant just
"make a game and earn robux"
you might be able to "make a game"
its js an obby game yk
you need skill to even make 10 robux
i already explained the issue
ok add me
alright
re-explain
the script is searching for checkpoints that are under workspace with the name "CheckpointX"
well eaither way
** You are now Level 2! **
your method did NOT work
womp womp
learn to script
make your own code
you'll make games 10000% faster
trust me
yeah this is the only thing i really need
womp womp