Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My obby script doesn't work. I tried everything, any help?

Asked by 3 years ago

Hi. I have a difficulty chart game, I am the scripter for it. But this script doesn't work. I tried everything. It worked last time, and I even tried reverting the game.

  local ting = 0 --debouncer

function onTouched(hit)

    if ting == 0 then
    ting = 1
    local check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button

    if check ~= nil then

        local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
        local stats = user:findFirstChild("leaderstats") 

        if stats ~= nil then 
            local stage1 = game.Workspace.Obbies["Extremely Easy"]:FindFirstChild(stats.Stage.Value)
                          check.Parent.HumanoidRootPart.Position = stage1.Position + Vector3.new(0,10,0)

                local stage2 = game.Workspace.Obbies["If you die..."]:FindFirstChild(stats.Stage.Value)
                          check.Parent.HumanoidRootPart.Position = stage2.Position + Vector3.new(0,10,0)

                local stage3 = game.Workspace.Lobby:FindFirstChild(stats.Stage.Value)
                          check.Parent.HumanoidRootPart.Position = stage3.Position + Vector3.new(0,10,0)

                    local stage4 = game.Workspace.Obbies["Easy"]:FindFirstChild(stats.Stage.Value)
                          check.Parent.HumanoidRootPart.Position = stage4.Position + Vector3.new(0,10,0)
            end
            wait() 
        end

    end

    ting = 0 
    end

script.Parent.Touched:connect(onTouched)

The error:

  19:53:51.287 - Workspace.Teleporter2.Teleporter.Script:16: attempt to index nil with 'Position'
19:53:51.287 - Stack Begin
19:53:51.288 - Script 'Workspace.Teleporter2.Teleporter.Script', Line 16 - function onTouched
19:53:51.288 - Stack End

Also, this script is a SCRIPT. Not a Local_Script.

If anyone can find the issue here, that would be greatly appreaciated.

NOTE:

The checkpoints are named like numbers, 1 2 3 4. The checkpoints ARE in the CORRECT area.

This script worked, but now it doesn't ...

Thank you, -GuestHacks666

1 answer

Log in to vote
0
Answered by 3 years ago

Variables can’t be numbers. Rather than “stage1” you would put “stageOne”. https://developer.roblox.com/en-us/articles/Variables

0
I renamed the "Stage 1" and other names to "stageone" yeah... But the error is still there. Not teleporting! GuestHacks666 20 — 3y
0
13:34:02.346 - Workspace.Teleporter2.Teleporter.Script:16: attempt to index nil with 'Position' 13:34:02.346 - Stack Begin 13:34:02.347 - Script 'Workspace.Teleporter2.Teleporter.Script', Line 16 - function onTouched 13:34:02.347 - Stack End GuestHacks666 20 — 3y
0
Nvm. I just some of the script into different scripts! GuestHacks666 20 — 3y
Ad

Answer this question