So I scripted this part that follows you and everything, but there is a problem where there is supposed to be only one part that following the person but when you press play, there is two. If you dont get what I am saying here is a video robloxapp-20210228-1047017.wmv (1.4 MB) .
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
When pasting code could you please use the Preformatted Text option? This will help to read the script easier.
It seems like you’re cloning the pet, which is already in workspace, so you’re going to get two of them. If you dont want to see the source, I’d suggest putting that into Replicated Storage, and use the script to move the close into the workspace.
To preformat text just place a
“```lua” at the start of your text, then end with “` ``” (no space)
-- ```lua
local Example = "See?"
-- ```
Anyways, your script does exactly what you tell it to do, your “problem” is that the source part is visible.
What your script does is take a copy of the part, then make it follow the player, this leaves the original part where it is. Here is what I would suggest doing:
Rename the part to “Shrek” or whatever you choose.
Place the part you would like to follow the player into game>ReplicatedStorage
Move the script that’s underneath the part to game>ServerScriptService
Then delete line 1 (local pet = script.Parent) and replace it with
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local pet = ReplicatedStorage:FindFirstChild("Shrek") -- Replace "Shrek" with whatever you decide to name the part.