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

teleport data script doesn't seem to work for some reason?

Asked by 3 years ago

i've been trying to do a teleport data script.. and it doesn't seem to work, heres the "send data" script im using..

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local test = game.Players.LocalPlayer.leaderstats.Chords
local teleportPart = script.Parent
local targetPlaceID = 6490820945  -- Change this to your place ID

-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

local function onPartTouch(otherPart)
    -- Get player from character
    local player = Players:GetPlayerFromCharacter(otherPart.Parent)

    if player and not player:GetAttribute("Teleporting") then
        player:SetAttribute("Teleporting", true)

        -- Define teleport options
        local teleportOptions = Instance.new("TeleportOptions")

        -- Set teleport data with player's health
        local getchords = test.Value
        if getchords then
            local teleportData = {
                currentHealth = test.Value
            }
            teleportOptions:SetTeleportData(teleportData)
        end

        -- Teleport the player
        local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player}, teleportOptions)

        player:SetAttribute("Teleporting", 6490820945)
    end
end

teleportPart.Touched:Connect(onPartTouch)

and here is the "retrieve data" script

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local test = game.Players.LocalPlayer.leaderstats.Chords
local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:Wait()
end

-- Read teleport data
local teleportData = TeleportService:GetLocalPlayerTeleportData()

if teleportData and teleportData.currentHealth then
    -- Set player health to passed value
    local getchords = test.Value + 100
    getchords.test.Value = teleportData.currentHealth
end

if you have any idea of how to make this work.. please let me know, i've been trying to do this for days now, so i'd REALLY appreciate it!

0
Can I see the game your making? That way, i get a better understanding of what your doing Xyternal 247 — 3y

Answer this question