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)