Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Not Teleporting If Bool Value True?

local DSS = game:GetService("DataStoreService")
local Storage = DSS:GetDataStore("Score")

local Door = script.Parent
local GoTo = game.Workspace.GardenAreaTP
local debounce = true

game:GetService("Players").PlayerAdded:Connect(function(player)
    local bool = Instance.new("BoolValue")
    bool.Name = "RemoveDoor1"
    bool.Value = false
    bool.Parent = player

    local success, result = pcall(function()
        Storage:GetAsync(player.UserId)
    end)

    if not success then
        warn(result)
    else
        local LoadValue = Storage:GetAsync(player.UserId)
        if LoadValue then
            bool.Value = LoadValue
            print(bool.Value)
        end
    end
end)

game:GetService("Players").PlayerRemoving:Connect(function(player)
    Storage:SetAsync(player.UserId, player:WaitForChild("RemoveDoor1").Value)
end)

Door.Touched:Connect(function(hit)
    if debounce == false then return end
    debounce = false
    print("Door Hit")
    local human = hit.Parent:FindFirstChild("Humanoid")
    if human ~= nil then
        print("Human touched door")
        local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
        if player ~= nil then
            local sp = player:WaitForChild("leaderstats"):WaitForChild("Coins")
            local check = player:WaitForChild("RemoveDoor1")
            if check.Value == false and sp.Value >= 1000000 then
                print("Human passed test")
                check.Value = true
                sp.Value = sp.Value - 1000000
                player:WaitForChild("Humanoid").CFrame = CFrame.new(GoTo.Position)
            elseif check.Value == true then
                print("Human already has access")
				player:WaitForChild("Humanoid").CFrame = CFrame.new(GoTo.Position)
            end
        end
    end
    debounce = true
end)

That is my script and i want the player to be teleported to the parts position. Everything works its just the error is in like line 48 and 51. Somebody help meehh,

2 comments

0

try doing player.Character:WaitForChild("Humanoid") instead of player:WaitForChild("Humanoid")

0

The mistake is very clear... You didn't define what "player" actually is.

1 answer

Many of us have mistaken the player for the character. The character is the actual physical player where the humanoid is located. So for lines 48 and 51 you’d need to do

player.Character:FindFirstChild(“Humanoid”) —etc

However, Humanoid does not have a cframe as it’s not a physical object. I think the best course of action is to move the HumanoidRootPart

This discussion is preserved as it was. New answers, comments, and votes are closed.