Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does it follow me when its a part but not a Model?

Can any body help me? I'm having trouble making a Model follow me. I it works with a part, but I have a bee model and I want that to follow me, but it doesn't work. Can anybody tell me how I can fix it?

This is the script that I put in a part and it follows me:

local pet = script.Parent

function givePet (player)
	if player then
		local character = player.Character
		if character then
			local humRootPart = character.HumanoidRootPart
			local newPet = pet:Clone ()
			newPet.Parent = character

			local bodyPos = Instance.new("BodyPosition", newPet)
			bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

			local bodyGyro = Instance.new("BodyGyro", newPet)
			bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)

			while wait() do
				bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, 3)
				bodyGyro.CFrame = humRootPart.CFrame
			end
		end
	end
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		givePet(player)
	end)
end)

But when I put that script in a model, it wont work. Can anybody tell me why?

1 comment

0

Weld the model, I'd put Q perfection weld in the model

1 answer

Ok so you have a really easy problem here. I don't know if you you know this already, but in line 18, you cannot use vector 3 for models. You have to use CFrame, or MoveTo()

3 comments

0

But I have a error then that says " Workspace.Model.Script:13: invalid argument #3 (Vector3 expected, got CFrame)", can you help me?

0

And when I use MoveTo:

0

hmm. So you know you have to do MoveTo(Vector3.new(x,y,z)) in order for it to work?

This discussion is preserved as it was. New answers, comments, and votes are closed.