Help with Bring command

I’m trying to create a bring command that bring the given name that is typed in the command bar. It does bring the typed player and all that, but when that brought player dies, their body is put back to where they were before they were brought.

Here’s my Local Script:

local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character
local Remote = game:GetService("ReplicatedStorage").BringRemote

local playerusernamebox = script.Parent.Parent:WaitForChild("PlayerUsername")

script.Parent.MouseButton1Up:Connect(function()
	local playerToBring = playerusernamebox.Text
	local Searchplayer = game.Workspace:FindFirstChild(playerToBring)
	if Searchplayer then
		local playerToBringHRP = Searchplayer:WaitForChild("HumanoidRootPart")
		Remote:FireServer(playerToBringHRP)
	end
end)

and here’s my server script:

local Remote = game:GetService("ReplicatedStorage").BringRemote

Remote.OnServerEvent:Connect(function(plr, playerToBringHRP)
	local CallerChar = plr.Character
	local CallingCharHRP = plr.Character:WaitForChild("HumanoidRootPart")
	if plr and CallingCharHRP and playerToBringHRP then
		playerToBringHRP.CFrame.Position = CallingCharHRP.CFrame.Position
		playerToBringHRP.Origin.Position = CallingCharHRP.Origin.Position
		
		print("Successfully brought " .. playerToBringHRP.Parent.Name .. " to " .. plr.Name)
	end
end)

and yes, I did get errors saying that Position isn’t valid and that origin isn’t valid (I need help on that as well please.)

Please help, thanks!

Why don’t you use PivotTo on the character model instead.

i.e.

local Remote = game:GetService("ReplicatedStorage").BringRemote
Remote.OnServerEvent:Connect(function(plr, playerToBring)
	playerToBring.Character:PivotTo(plr.Character:GetPivot())
end)

1 Like

Try what @SeargentAUS said.

The problem might be that you are just CFraming the HumanoidRootPart and breaking the neck weld, killing the player.

no setting cframe of root is fine i’ve been doing it for a long time for teleporting characters, problem might be some weird thing about setting origin since you dont need to do that.

Your using position, instead use CFrame.

oh yeah @silencemotions noticed it

you are trying to set the position property of a CFrame

do either
playerToBringHRP.CFrame = CallingCharHRP.CFrame
or
playerToBringHRP.Position = CallingCharHRP.Position
you cannot do CFrame.Position =

Thisd worked! Thank you so much for the help!

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