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

What should I replace Local Player with?

Ok so I made this pathfinding script but it says that LocalPlayer is a nil value. What other variable should i use. Here is my script.



while wait() do
	local path = game:GetService("PathfindingService")
	path:ComputeRawPathAsync(script.Parent.Torso.Position,
	game.Players.LocalPlayer.Character.Torso.Position)
		if path.Status == Enum.PathStatus.Success then
			local points = path:GeetWaypoints()
			if#points < 3 then
				script.Parent.Humanoid:MoveTo(game.Players.LocalPlayer.Character.Torso.Position)
		else
			script.Parent.Humanoid:MoveTo(points[3])
			end
		else
				script.Parent.Humanoid:MoveTo(game.Players.LocalPlayer.Character.Torso.Position)
		end
end

function OnTouched()
	script.Parent.Torso.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild('Humanoid') then
			hit.Parent.Humanoid.Health = 0
		end
	end)
end

3 comments

0

scripts not in script holder :/

0

run it in a local script so you can use local player. pathfinding should be done on the client if it's pathfinding for the player. if it's an NPC, you already know what character you are going to use so you can replace the character variable with the npc

0

the script is inside the npc.

1 answer

What is would do is try every script. More than likely local script, but I don’t know. Maybe try ‘player’ instead.

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