Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Attemp to Connect Failed: passed value is not a function?

the error on line 1

game.Players.PlayerAdded:connect(onPlayerRespawned)
function onPlayerRespawned(newPlayer)
 wait(1)
 if newPlayer.Name == "killzone45671" then --Change Wacon to your name.
  local gui=Instance.new("BillboardGui")
  gui.Parent=newPlayer.Character.Head
  gui.Adornee=newPlayer.Character.Head
  gui.Size=UDim2.new(3,0,3,0)
  gui.StudsOffset=Vector3.new(0.5,2,0)
  local text=Instance.new("ImageLabel")
  text.Image = "http://www.roblox.com/asset/?id=50540825" 
  text.Size=UDim2.new(1,0,1,0)
  text.Position=UDim2.new(-0.125,0,-0.25,0)
  text.BackgroundTransparency = 1
  text.Parent=gui
 end
end

function onPlayerEntered(newPlayer)
 newPlayer.Changed:connect(function (property)
  if (property == "Character") then
   onPlayerRespawned(newPlayer)
  end
 end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)

1 comment

0

game.Players.PlayerAdded:connect(function(onPlayerRespawned) fix the first line

1 answer

You have to declare the function first, then connect it.

This discussion is preserved as it was. New answers, comments, and votes are closed.