Hello developers. I have script that handles data, checkpoint, teleport and some other systems but after the “Player.CharacterAdded:Connect(function(Character)” line it stops working without any errors. Its not updating the checkpoints when you touch to new checkpoint part and its not teleporting player to the current stage. Here’s the script.
Player.CharacterAdded:Connect(function(Character)
print('after_line')
wait() -- Ensure character is fully loaded
local Humanoid = Character:WaitForChild('Humanoid')
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
-- Ensure stage is within valid bounds
local stageValue = Player.leaderstats.Stage.Value
if stageValue <= #Checkpoints:GetChildren() then
Teleport.Player(Player, Checkpoints[stageValue].CFrame)
end
-- Set player walk speed based on GamePass ownership
Humanoid.WalkSpeed = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 662270121) and 32 or 16
-- Add a small delay after teleportation to prevent immediate checkpoint collisions
wait(0.5)
-- Checkpoint touch event
Humanoid.Touched:Connect(function(hit)
if hit:IsDescendantOf(Checkpoints) then
local checkpointNumber = tonumber(hit.Name)
if checkpointNumber == Player.leaderstats.Stage.Value + 1 then
Player.leaderstats.Stage.Value += 1
Sound.Player(Player, Sound.Checkpoint)
game.ReplicatedStorage.events.Client:FireClient(Player, 'Checkpoint')
Player.leaderstats.Coins.Value += 5
Player.Stats.XP.Value += 15
elseif checkpointNumber > Player.leaderstats.Stage.Value + 1 then
Notify.Small(Player, 5, 'No cheating >:c')
Player:LoadCharacter()
end
end
end)
end)
end)
are you sure that the code stops on .CharacterAdded?? put that before print somewhere else
also… ugh, for the future, please avoid relying on GPT for your programming career, it’s not good practice and will not do you any good, use GPT for debugging, not for writing entire scripts
i can very much tell this code is AI-Generated, i won’t flame you for it, but just a heads up
(or if you’re gonna keep on using AI generated code atleast remove the comments the AI gives you so it’s not that obvious )
its not fully Ai-Generated. I tried to fix with ai but it didnt work. if you want originial script:
Also, I tried print and it stops printing after that line.
Player.CharacterAdded:Connect(function(Character)
print('after_line')
wait()
local Humanoid = Character:WaitForChild('Humanoid')
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
Teleport.Player(Player, Checkpoints[Player.leaderstats.Stage.Value].CFrame)
Humanoid.WalkSpeed = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 662270121) and 32 or 16
Humanoid.Touched:Connect(function(hit)
if hit.Parent == Checkpoints then
if tonumber(hit.Name) == Player.leaderstats.Stage.Value + 1 then
Player.leaderstats.Stage.Value += 1
Sound.Player(Player, Sound.Checkpoint)
game.ReplicatedStorage.events.Client:FireClient(Player, 'Checkpoint')
Player.leaderstats.Coins.Value += 5
Player.Stats.XP.Value += 15
elseif tonumber(hit.Name) > Player.leaderstats.Stage.Value + 1 then
Notify.Small(Player, 5, 'No cheating >:c')
Player:LoadCharacter()
end
end
end)
end)
end)
this code is literally the same line for line… just without comments
…sigh
can i have a video of the issue happening? along with each module’s responsibility
(i apologize for the “aggression”, but i’ve seen a bit of bluntly AI generated code with people claiming “i made this” and it’s kind of getting on my nerves now)