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

Why is GetLocalPlayerTeleportData always appearing as 0 when teleported?

Asked by 4 years ago

Backstory

Basically I'm trying to make a character customization system. When ever a player clicks these two arrows it basically give this rig in the game hair to tell the player what the hair looks like. I've done this with Skin Colour,Face,Shirt,etc but I'll use hair for this question. Also, when the player clicks these arrows it will put a Int-Value inside of the rig. There will be a value inside that rig which will depend what the item is. For example Hair1 would be interger 1 or Hair2 would be interger 2. When the player clicks another gui button the player is teleported to the Main place where the quest,Leveling,etc happens.

Problem

When the player joins I use the GetLocalPlayerTeleportData to fetch the data I'm sending which is Int-Value in the rig. For this question it will be 1 but when I fetch that interger for some reason it turns to a 0. I'm using this code to tell the game to give them hair depending on the number:

if teleportdata == 1 then
        print("teleportdata = 1")
        local Hair1 = game.ReplicatedStorage.CharacterCustomization.Hair1.Hair1:Clone()
        Hair1.Parent = Player.Character
    end

Teleport service is really annoying because you have to do this in game instead of studio so I have to print the Int-Values Value every few seconds. I really don't know why this is happening and it would be very appreciated for some help.

Local Script

local TeleportService = game:GetService("TeleportService")
local Player = game.Players.LocalPlayer

print("Huh?!/")
print(":Like sas")

local teleportdata = TeleportService:GetLocalPlayerTeleportData()


if teleportdata then
    print("sending")
    print(teleportdata)
    game.ReplicatedStorage.CharacterCustomization.RemoteEvent:FireServer(teleportdata)
    print("sent")
end

while wait(2) do
for i,v in pairs(Player:GetChildren()) do
    print(Player:WaitForChild("HairInt").Value)
end
end

if teleportdata == nil then

end

Server Script

game.ReplicatedStorage.CharacterCustomization.RemoteEvent.OnServerEvent:Connect(function(Player,teleportdata)
    local Int = Instance.new("IntValue")
    Int.Name = "HairInt"
    Int.Value = teleportdata
    Int.Parent = Player
    if teleportdata == 1 then
        print("teleportdata = 1")
        local Hair1 = game.ReplicatedStorage.CharacterCustomization.Hair1.Hair1:Clone()
        Hair1.Parent = Player.Character
    end
end)

The random prints are to make sure that the game got published when I'm playing it.

Answer this question