Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Local 'char' is a nil value?

Asked by 6 years ago

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

Log in to vote
0
Answered by
Acryius 22
6 years ago
Edited 6 years ago
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!

0
Let's not say "is now called 'UpperTorso' " , please. User#17685 0 — 6y
0
Well, it doesn't work with a moving object, how to make this work with a moving object? Theroofypidgeot 21 — 6y
0
Also after you did it once, it doesn't function anymore Theroofypidgeot 21 — 6y
Ad

Answer this question