-
What do you want to achieve? Keep it simple and clear!
I need to get the player in a serverscript so i can teleport the player
using teleportService when he clicks on a gui -
What is the issue? Include screenshots / videos if possible!
This is the script that creates the button
local worlds = script.Parent.Parent.Worlds
local button = script.Parent
local Value = script.Parent.Parent.Configuration.Value
local maxWorlds = false
local World = nil
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
if maxWorlds == false then
World = script.Parent.Parent.Parent.Replicated.World:Clone()
World.Parent = worlds
World.Name = "World" .. Value.Value
World.Text = "World" .. Value.Value
World.Visible = true
World.TextScaled = true
Value.Value += 1
end
if Value.Value == 6 then
maxWorlds = true
button.Text = "Max Worlds Reached"
end
end)
this is the script that teleport the player
script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local teleportService = game:GetService("TeleportService")
teleportService:TeleportAsync(15333331947, {player})
end)