Does anyone know how to fix this?

Does anyone know how I can fix this -
It’s teleporting every player because of this line of code. It’s getting all the children under players.

-- local p = game.Players:GetChildren()

FULL CODE -

function onClicked()
	local p = game.Players:GetChildren()
	for i = 1, #p do
		p[i].Character:MoveTo(Vector3.new(53.585, 1.109, 85.692))
	end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Well what do you want to achieve?
Only the player clicking to teleport?

1 Like
local Players = game:GetService('Players')
script.Parent:FindFirstChildOfClass('ClickDetector').MouseClick:Connect(function()
	for __, Player in pairs(Players:GetPlayers()) do
		local PlayerCharacter = Player.Character
		if PlayerCharacter then
			PlayerCharacter:MoveTo(Vector3.new(53.585, 1.109, 85.692))
		end
	end
end)
1 Like

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