RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Workspace.Teleport Pads.Script:5: attempt to index nil with 'leaderstats'"
Sorry for the confusion, the error means that 'leaderstats' does not exist for the player. This could be because the player does not have a leaderstats value or it has not been initialized yet. Here's a corrected version: ```lua local player = game.Players.LocalPlayer -- Check if player has leaderstats if player:FindFirstChild("leaderstats") then local rebirths = player.leaderstats.Rebirths local pad1 = game.Workspace.Pad1 local pad2 = game.Workspace.Pad2 local function teleport(character, destination) character:MoveTo(destination.Position) end pad1.Touched:Connect(function(hit) local character = hit.Parent:FindFirstChild("Humanoid") if character and rebirths.Value >= 3 then teleport(character, pad2) end end) pad2.Touched:Connect(function(hit) local character = hit.Parent:FindFirstChild("Humanoid") if character then teleport(character, pad1) end end) else print("Player does not have leaderstats") end ``` This script checks if the player has 'leaderstats' before trying to access it. If 'leaderstats' does not exist, it prints a message to the console.