Script doesn't work, script says part doesn't exist. Checked ingame, part is there

Script in Client does not work, error is “destination doesn’t exist in workspace”

local Players = game:GetService("Players")
local GoTo = game.Workspace.destination
local tp3 = script.Parent

tp3.Touched:Connect(function(hit)
	local w = hit.Parent:FindFirstChild("HumanoidRootPart")
	for i,v in pairs(game.Players:GetPlayers()) do
	Players.PlayerAdded:Connect(function(player)

		local char = player.Character
		local humanoid = char:FindFirstChild("Humanoid")

		--Force player to walk to the GoTo
		local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()---GetControls
		Controls:Disable() 
		humanoid:MoveTo(GoTo.Position)
			v.Humanoid.Jump = true
			wait(.5)
			v.Humanoid.Jump = true
		wait(5)


	end)
	end
end
)

1 Like

Add WaitForChild("Part"). Also, you can use just workspace instead of game.Workspace

1 Like

Whereto add waitforchild part?

1 Like

After Workspace (or game.workspace if you didn’t change it)

1 Like

No errors, but script doesn’t seem to force me to walk in any way…

1 Like

That’s because :MoveTo teleports I believe. I wish it was that easy lol.

1 Like

It doesn’t do anything . No teleportation, no nothing.

1 Like

I think it’s trying to move an inanimate object (humanoid) to a position. Try using a model like a character.

1 Like

I replaced “humanoid” with “char”. Still no progress…

1 Like

Try FindFirstChild() instead of WaitForChild() maybe.

1 Like

Also make sure that the destination part has CanCollide or Anchored enabled, it might be falling through the map and into the void which could be why the script can’t find it.

1 Like

No errors, still does absolutely nothing.

1 Like

CanCollide is not on. Anchored is on. Cannot fall thru.

1 Like

The not found error is gone. It just now does not work.

1 Like

Probably because instead of instantly making all of the players move to the destination, you’re waiting until Players.PlayerAdded.

1 Like
local Players = game:GetService("Players")
local GoTo = game.Workspace.destination
local tp3 = script.Parent

tp3.Touched:Connect(function(hit)
	local w = hit.Parent:FindFirstChild("HumanoidRootPart")
	for _,player in pairs(game.Players:GetPlayers()) do
		local char = player.Character
		local humanoid = char:FindFirstChild("Humanoid")

		local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()---GetControls
		Controls:Disable() 
		humanoid:MoveTo(GoTo.Position)
			v.Humanoid.Jump = true
			wait(.5)
			v.Humanoid.Jump = true
		wait(5)
	end
end)

Try this.

Also, are you trying to get all players to walk to the destination once the part is touched or are you trying to get the player who touched the part to walk there?

1 Like

Player who touched, but the game is singleplayer so it doesn’t matter.

1 Like

image

1 Like

Error is back! Woohoo.

1 Like

Oh yeah that’s probably because I didn’t include :FindFirstChild() in the script, use that and it should work fine.

1 Like