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

Local 'char' is a nil value?

I got the error:

Workspace.ZiplineHolder.DatpartWhereUStickTo.Script:6: attempt to index local 'char' (a nil value)

What does this mean, and how do I fix it?

This is the script I used


game.Players.PlayerAdded:Connect(function(p)
  local char = workspace:FindFirstChild(p.Name)
  local part = script.Parent -- part
  local time = 2 -- amount of time
 local place = CFrame.new(part.Position) -- Where you want the player to go on touched
repeat wait(1) time = time - 1 char.Torso.CFrame = place until time < 1
end)

1 answer

game.Players.PlayerAdded:Connect(function(p)
	  local char = game.Workspace:WaitForChild(p.Name)
	  local part = script.Parent -- part
	  local time = 2 -- amount of time
	 local place = CFrame.new(part.Position) -- Where you want the player to go on touched
	repeat wait(1) time = time - 1 char.Torso.CFrame = place until time < 1
	end)

If there still a problem let me know.

also if the player is using R15 this script will not work because "Torso" is now called UpperTorso!

3 comments

0

Let's not say "is now called 'UpperTorso' " , please.

0

Well, it doesn't work with a moving object, how to make this work with a moving object?

0

Also after you did it once, it doesn't function anymore

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