I'm trying to have a local script fire a remote event to the server that allows a player to join a team of their choosing. The exact error message I receive is
16:45:25.304 - Workspace.Event Handler:10: attempt to index local 'playa' (a nil value)
Through printing what playerName and teamName are in the server script I've determined that both varibles are the string "stardon" Why? One should be a team and not a text string.
Here are my scripts
Local GUI script
function click()
--Arguments to pass toward the server script
local PN = script.Parent.Parent.Parent.Parent.Parent.Parent.Name
local targetTN = game.Teams[script.Parent.Text]
--Pass em' to the server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GiveMeJob = ReplicatedStorage:WaitForChild("GiveMeJob")
GiveMeJob:FireServer(PN, targetTN)
end
script.Parent.MouseButton1Click:connect(click)
Server Event Handling Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GiveMeJob = ReplicatedStorage:WaitForChild("GiveMeJob")
local spawns = game.Workspace.SpawnLocations:GetChildren()
local function hereIsJob(playerName, teamName)
wait(0.1)
print(teamName)
local targetTeamColor = teamName.TeamColor
local playa = game.Players:FindFirstChild(playerName)
playa.Team = teamName
for i=1, #spawns do
if spawns[i].teamName == targetTeamColor then
playa.Character:MoveTo(spawns[i].Position + Vector3.new(0,10,0))
end
end
end
GiveMeJob.OnServerEvent:Connect(hereIsJob)

4 comments
Try 'local PN = game.Players.LocalPlayer.Name'
I'm having the same problem. It still thinks both values I pass along are "stardon"
The first argument of a remote event sent from client-server is already the player's name automatically, your first two arguments both send the player name and the third argument isn't received by the server
Oh! Thanks a bunch!