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

My character does not teleport. What can i do?

Asked by 3 years ago
Edited 3 years ago

I am new to scripting so sorry if its a stupid error. I am making a game where you have to fight with others with a sword and it gives me an error at the command: character:FindFirstChild("HumanoidRootPart").CFrameAvaliableSpawnPoints[1].CFrame This have to teleport you at the first spawnpoint found in a table. In the table are all the spawnpoints. I hope you understand what is my problem.

    local AvaliableSpawnPoints = SpawnPoints:GetChildren()
    for i, player in pairs(plrs) do
        if player then
            character = player.Character

            if character then 
                character:FindFirstChild("HumanoidRootPart").CFrame = AvaliableSpawnPoints[1].CFrame
                table.remove(AvaliableSpawnPoints, 1)


                local Sword = ServerStorage.Sword:Clone()
                Sword.Parent = player.Backpack

                local GameTag = Instance.new("BoolValue")
                GameTag.Name = "GameTag"
                GameTag.Parent = player.Character

            else
                if not player then
                    table.remove(plrs,i)
                end
            end
        end
    end
0
Does this code runs right when the player spawns? Necro_las 412 — 3y
0
What error the output shows up? Necro_las 412 — 3y
0
attempt to index nil with 'CFrame' RaZe23140 0 — 3y

1 answer

Log in to vote
0
Answered by
extrorobo 104
3 years ago

you can use this script instead to make someone teleport with a premium membership

local MarketplaceService = game:GetService("MarketplaceService") local TeleportService = game:GetService("TeleportService") local Players = game:GetService("Players")

local teleporter = script.Parent local showPrompt = true

local placeID_Premium = 151806869 -- Insert place ID here; can be found in web address bar on the game's page

local function onTeleporterTouch(otherPart)

local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if not player then return end

-- If the user already has Premium, teleport them to the Premium-only place
if player.MembershipType == Enum.MembershipType.Premium then
    TeleportService:Teleport(placeID_Premium, player)
-- Else, prompt Premium upgrade (use debounce to show it only once every few seconds)
else
    if showPrompt == false then return end
    showPrompt = false
    delay(5, function()
        showPrompt = true
    end)
    MarketplaceService:PromptPremiumPurchase(player)
    warn("Prompted Premium purchase")
end

end teleporter.Touched:Connect(onTeleporterTouch)

-- If needed, use this event to know when the Premium modal is closed MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player) warn("Upsell modal closed") end)

-- Handle potential Premium purchase from outside the game while user is playing Players.PlayerMembershipChanged:Connect(function(player) warn("Player membership changed; new membership is " .. tostring(player.MembershipType)) if player.MembershipType == Enum.MembershipType.Premium then -- Teleport player to the Premium-only place TeleportService:Teleport(placeID_Premium, player) end end)

0
Sorry, but my script does not need a premium membership, it's a necesary script that teleports the player at the battle arena :) RaZe23140 0 — 3y
0
wtf premium membership? Necro_las 412 — 3y
0
if you dont want the premium membership u can change it in enum membership type extrorobo 104 — 3y
Ad

Answer this question