Get a model to move with the player

Hi Devs,
i need to get a model to move with the player just like the parts that make up the player
this is my code currently

--made by hellothere3681
local ev = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))
ev.Name = "rau"

local orb = game:GetService("ReplicatedStorage").singu

ev.OnServerEvent:Connect(function(plr)
	wait(1)
	--//-------------------------\\
	local char = plr.Character
	local HRP = char:WaitForChild("HumanoidRootPart")
	
	local clo = orb:Clone()
	clo.Parent = game.Workspace
	clo.skatter.Position = HRP.Position + HRP.CFrame.LookVector
	clo.Bomb.Position = HRP.Position + HRP.CFrame.LookVector
	
	local TweenService = game:GetService("TweenService")
	
	--//---------------------------------------\\
	--//--------------------------\\
	
	local goal = {}
	goal.Position = HRP.Position + HRP.CFrame.LookVector * 10
	goal.Size = Vector3.new(12, 12, 12)

	local tweenInfo = TweenInfo.new(5)

	local tween1 = TweenService:Create(clo.skatter, tweenInfo, goal)

	tween1:Play()
	
	local goal = {}
	goal.Position = HRP.Position + HRP.CFrame.LookVector * 10
	goal.Size = Vector3.new(11.5, 11.5, 11.5)


	local tween2 = TweenService:Create(clo.Bomb, tweenInfo, goal)

	tween2:Play()
	--//---------------------------------------------------\\
	local moving = false
	wait(4)
	local atch = Instance.new("Attachment", HRP)
	clo.Parent = atch
	local bv = Instance.new("BodyVelocity", clo.Bomb)
	char.Humanoid.WalkSpeed = 30

	local Humanoid = char.Humanoid


	
	
	local function onTouch(part)
		local hum = part.Parent:FindFirstChild"Humanoid"
		if hum and not part.Parent == char then
			print("HIT")
			ev:FireClient(game:GetService("Players")[part.Parent.Name])
			hum:TakeDamage(10)
		end
	end

	clo.Bomb.Touched:Connect(onTouch)
end)

All help is greatly appricated.

2 Likes

Use a :SetPrimaryPartCFrame or just set a primarypart’s cframe, it will teleport all models to the specific location

1 Like

Does that make it so that my model will automatically move with the player?

1 Like

No, but you can use weld after you TP a model to a player

1 Like

This doesn’t work no errors and i have set it to the CFrame

1 Like

I sure that the script you use is from a client side, right?

1 Like

No i was using server script

more charaters

1 Like

I still dont know where you put it in, can you show me your script?

1 Like

all server script

--made by hellothere3681
local ev = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))
ev.Name = "rau"

local orb = game:GetService("ReplicatedStorage").singu

ev.OnServerEvent:Connect(function(plr)
	wait(1)
	--//-------------------------\\
	local char = plr.Character
	local HRP = char:WaitForChild("HumanoidRootPart")
	
	local clo = orb:Clone()
	clo.Parent = game.Workspace
	clo.skatter.Position = HRP.Position + HRP.CFrame.LookVector
	clo.Bomb.Position = HRP.Position + HRP.CFrame.LookVector
	clo:SetPrimaryPartCFrame(HRP.CFrame)
	
	local TweenService = game:GetService("TweenService")
	
	
	--//---------------------------------------\\
	--//--------------------------\\
	
	local goal = {}
	goal.Position = HRP.Position + HRP.CFrame.LookVector * 10
	goal.Size = Vector3.new(12, 12, 12)

	local tweenInfo = TweenInfo.new(5)

	local tween1 = TweenService:Create(clo.skatter, tweenInfo, goal)

	tween1:Play()
	
	local goal = {}
	goal.Position = HRP.Position + HRP.CFrame.LookVector * 10
	goal.Size = Vector3.new(11.5, 11.5, 11.5)


	local tween2 = TweenService:Create(clo.Bomb, tweenInfo, goal)

	tween2:Play()
	--//---------------------------------------------------\\
	local moving = false
	wait(4)
	char.Humanoid.WalkSpeed = 30

	local Humanoid = char.Humanoid

	--[[local VectorZero = Vector3.new(0, 0, 0)

	local function Moved()		
		if Humanoid.MoveDirection ~= VectorZero then
			clo.Bomb.Position = (HRP.Position + HRP.CFrame.LookVector * 10) + HRP.CFrame.LookVector * 10
			clo.skatter.Position = (HRP.Position + HRP.CFrame.LookVector * 10) + HRP.CFrame.LookVector * 10
		end	
	end

	Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(Moved)]]
	
	
	local function onTouch(part)
		local hum = part.Parent:FindFirstChild"Humanoid"
		if hum and not part.Parent == char then
			print("HIT")
			ev:FireClient(game:GetService("Players")[part.Parent.Name])
			hum:TakeDamage(10)
		end
	end

	clo.Bomb.Touched:Connect(onTouch)
end)
1 Like

I still dont know why you put
OnServerEvent:Connect(function(plr) as it a server side function

what is wrong with that? its the event fired by the player

He said that he was using a server script.

I’m quite sure that you can use SetPartCFrame() and weld the part to your characters HumanoidRootPart. I would give an example of a welding script but Im not too familiar with them. Im sure there are plenty of tutorials on YouTube though.

Oh sorry, i messed up a little bit.

1 Like

its fine we all make mistakes its actually the Britch army moto “Fail, Learn, Succeed”

are you sure this is a thing i looked it up on the API references and cant find anything

Classic Baseplate - Roblox Studio (gyazo.com)

is this what you expected?

yes pretty much
faffhuifhufhushfefsf

Yea I said it wrong. My bad. I meant SetPrimaryPartCFrame()

oh thank you really helps have a good day