Why does this script say "argument 1 missing or nil"?

local player = game.Players.LocalPlayer

db = false
game.ReplicatedStorage.PlayerRail.OnClientEvent:Connect(function(playerac, name)
	print("good")
	db = false
	for i = 1, 6 do
		if db == false then
			player.Character.HumanoidRootPart.Anchored = true
			local crusher = game.Players.LocalPlayer.Character.HumanoidRootPart
			crusher.CFrame = game.Workspace.Rails:WaitForChild(name):WaitForChild(i):WaitForChild("Attachment1").CFrame
			local TweenService = game:GetService("TweenService")
			local crushinfo = TweenInfo.new(
				0.5,
				Enum.EasingStyle.Linear, 
				Enum.EasingDirection.Out,
				0, 
				false,
				0 
			)
			local crushgoal = {
				CFrame = game.Workspace.Rails:WaitForChild(name):WaitForChild(i):WaitForChild("Attachment").CFrame
			}
			local tween = TweenService:Create(crusher, crushinfo, crushgoal)
			tween:play()
		end
		wait(0.5)
	end
end)

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space then
		db = true
		player.Character.HumanoidRootPart.Anchored = false
	end
end)

The error is on line 11

What is “name”?

2 Likes

Parameter name’s value could be nil. Make sure to do print(name) to make sure it’s not nil.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.