Attempt to concatenate string with nil

It supposed to print it, but instead it’s just printing out an error that I can’t even fix.

local PlayerWhoGotArrested = ProxPrompt.ObjectText
			local WhoArrestPlayer = WhoArrestedPlayer.Name
			print(WhoArrestedPlayer.." arrested "..PlayerWhoGotArrested)
			if game.Players[PlayerWhoGotArrested].Team == game.Teams.Criminal then
				local JailTeleports = workspace.JailTeleports:GetChildren()
				local Index = math.random(1, #JailTeleports)
				local Selection = JailTeleports[Index]
				
				workspace[PlayerWhoGotArrested].HumanoidRootPart.CFrame = Selection.CFrame
			end

The print(WhoArrestedPlayer.." arrested "..PlayerWhoGotArrested) says

ServerScriptService.ArrestingSystemServer:39: attempt to concatenate string with nil

Please help

WhoArrestedPlayer or PlayerWhoGotArrested is nil
you can probably figure out how by using

print(`{WhoArrestedPlayer} arrested {PlayerWhoGotArrested}`)

since that wont give you a error it will just print it no matter what (nil arrested nil etc.)

edit: should help with debugging whats wrong with it

1 Like