What's the best way to make a teleport to tool system?

Hey!
I’m trying to make a teleport to the tool holder system but it keeps breaking because the method I’m using is unstable, and, I’m just checking if anyone can help me use a different system.
Thanks!

Still requiring help. Can anyone help?

When do you want this to happen, and who/what is the tool holder. Also can we see your “unstable” code

1 Like

I deleted the code, and, it happens when you click a block, the holder is another player.

Still not given any help, anyone?

Could we see some code, a photo of the hierarchy, or something from studio for us to help you?

If you are trying to make a tool that teleports everyone to it you could do something like this:

script.Parent.Activated:Connect(function()
game.ReplicatedStorage.ActivatedRE:FireServer()
end)

This would tell the server that they activated their tool
Then on the server you could do something like this to teleport everyone:

game.ReplicatedStorage.ActivatedRE.OnServerEvent:Connect(function(plr)
local tool = plr.Character:FindFirstChildWhichIsA("Tool")
if tool then
for i,v in pairs(game.Players:GetChlidren()
if v ~= plr then
v.Character:MoveTo(plr.Character.Head.Position)
end
end
end
end)

No, it just teleports the player who clicked to the flag. The way it works is that there’s a part for each team’s flag (tool) and when a player clicks on it they get teleported to their teams flag (tool).

Ok, sorry about not responding I was sleeping lol.

Is the part called flag? If so this code should work:

script.Parent.MouseClick:Connect(function(player)
    local character = player.Character
    for _, plr in pairs(game.Players:GetPlayers()) do
        if plr.Team ~= player.Team then continue end
        local char = plr.Character
        if not char:FindFirstChild("Flag") then continue end
        local clickerHRP = character.HumanoidRootPart
        local holderHRP = char.HumanoidRootPart
        clickerHRP.CFrame = holderHRP.CFrame
    end 
end)