Help with sharing data to leaderstats when click teleport button in local script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Im making a story mode GUI where the stages get harder so giving a player a number value to enable a script in the teleported place to be triggered.
  2. What is the issue? Include screenshots / videos if possible!
    My teleport script from my lobby is a local script so the StageSelect Value isnt regisered on the server so when the player teleports into the place the StageSelect value is still 0.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Ive looked online for tutorials on making a story GUI where you can select stages and cant find any. Anyone know of one?
    Or how can i make my StageSelect value be registered in my leaderstats in my datastore? I have read about remote events etc but not really sure how to apply it in this case.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block
local teleportGui = script.Parent
local Stage1 = teleportGui.Frame.Frame.Stage1.TextButton 
local Stage2 = teleportGui.Frame.Frame.Stage2.TextButton

local teleportService = game:GetService("TeleportService")


local player = game.Players.LocalPlayer

local placeID = 9566395887

Stage1.MouseButton1Up:Connect(function()
	player.leaderstats.StageSelect.Value = 1.1

	wait(2)
	teleportService:Teleport(placeID, player)
end)

Stage2.MouseButton1Up:Connect(function()
	player.leaderstats.StageSelect.Value = 1.2

	wait(2)
	teleportService:Teleport(placeID, player)
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Try using .Activated instead of .MouseButton1Up, because .MouseButton1Up only works on PC.

1 Like

Also I don’t think you can teleport a player in a LocalScript, and if that script is a server script, you cannot get the local player withhin a server script, but I might just be completly wrong.

It is a local script and does work.
Thankyou for your tip about .Activated. Ill change that.

Did you change it yet and tryied again? Or try adding a print inside the .Activated function to see if it even fires correctly

1 Like

Probably you need to send the data to that place also , there isn’t a need to use .Activated or anything , it’s just because in your other place , you haven’t loaded data which you need to

If you don’t have a very serious data you need to load , you can use this code

local TPS = game:GetService("TeleportService")

local teleportData = TeleportService:GetLocalPlayerTeleportData()

Add a local script in the place you want to teleport and add this code :slight_smile: Thanks

Hi yes i did and .Activated works thankyou

I managed to make this problem work by firing an event. Thankyou for all of your help :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.