I am trying to get the local player but I realized that it is on a non-local script. I am doing this:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
But I know that won't work. How should I do this?
Code for Script:
local oldMessage = ""
local minPlayers = 1
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local messagePlayerEvent = Instance.new("RemoteEvent")
messagePlayerEvent.Parent = game.ReplicatedStorage
messagePlayerEvent.Name = "MessagePlayerEvent"
function teleportPlayers()
local TeleportTarget = ""
local target = CFrame.new(workspace.StartP1.Position)
for i, player in ipairs(game.Players:GetChildren()) do
TeleportTarget = (string.format("StartP%s", i))
target = CFrame.new(workspace[TeleportTarget].Position)
player.Character.HumanoidRootPart.CFrame = target
player.Playing.Value = 1
end
end
function message(message)
if oldMessage ~= message then
oldMessage = message
print(message)
end
end
function playersCurrentlyPlaying()
for i, player in ipairs(game.Players:GetChildren()) do
if player.Playing.Value == 1 then return true end
end
return false
end
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
player.Playing.Value = 0
end)
end)
local playing = Instance.new("IntValue", player)
playing.Value = 0
playing.Name = "Playing"
end)
while(true) do
wait(10)
if #game.Players:getPlayers() >= minPlayers then
if playersCurrentlyPlaying() then
local text = "Waiting for an available arena..."
messagePlayerEvent:FireClient(player, text)
else
local text = "There are enough players for a new game! Teleporting..."
messagePlayerEvent:FireClient(player, text)
wait(4)
teleportPlayers()
end
else
local text = "Waiting for more players..."
messagePlayerEvent:FireClient(player, text)
end
end

6 comments
just dont use local player, and use the resources available to u. you've already done it so i dont rlly understand the issue. http://prntscr.com/mczyxp
The problem is it underlines where it says player when I use FireClient and has the warning of Unknown global 'player'
gioni the issue was at the end where he was sending a remote event to localplayer.
ok so u obviously havent defined player
ok good job dino man
yaya, i knew what was going on from a previous question. im not fixing the indention sorry its too many lines :(