i did
local function setPetNodes(petCount,overlapMultipler)
local rotationOffset = 360/petCount --Determine how much degrees must be seperated between pets
for petNode = 1,petCount do
local currentNode = Instance.new("Part")
currentNode.Name = "Pet Node "..petNode
currentNode.Size = Vector3.new(1,1,1)
currentNode.CFrame = CFrame.Angles(0,math.rad(rotationOffset*petNode),0) * CFrame.new(-game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector*math.max(petCount*overlapMultipler,4)) * game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
local weld = Instance.new("WeldConstraint")
weld.Parent = currentNode
weld.Part0 = game.Players.LocalPlayer.Character.HumanoidRootPart
weld.Part1 = currentNode
currentNode.Parent = game.Players.LocalPlayer.Character
end
end
local function setupPet(clone)
local node = setPetNodes(amountEquipped, 1)
local attachChar = Instance.new("Attachment")
attachChar.Visible = false
attachChar.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
local pos = Vector3.new(1,1,0)
attachChar.Position = pos
local attachPet = Instance.new("Attachment")
attachPet.Visible = false
attachPet.Parent = clone.PrimaryPart
local alignPos = Instance.new("AlignPosition")
alignPos.MaxForce = 25000
alignPos.Attachment0 = attachPet
alignPos.Attachment1 = node
alignPos.Responsiveness = 10
alignPos.Parent = clone
local alignOr = Instance.new("AlignOrientation", clone)
alignOr.MaxTorque = 25000
alignOr.Attachment0 = attachPet
alignOr.Attachment1 = node
alignOr.Responsiveness = 10
end
if amountEquipped < 5 and petModel.Equipped.Value == false and not game.Players.LocalPlayer.EquippedPets:FindFirstChild(petStringv) then
amountEquipped += 1
local clone = petModel:Clone()
petModel.Equipped.Value = true
clone.Parent = game.Players.LocalPlayer.Character
clone:SetPrimaryPartCFrame(game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame)
setupPet(clone)
local newPet = Instance.new("StringValue", game.Players.LocalPlayer.EquippedPets)
newPet.Name = petName
newPet.Value = game.Players.LocalPlayer.PlayerGui.GameGui.Inventory.PetInfo.PetView[clone.Name].Value
end
but it just spawns in a part that follows me
i would really appreiciate it if you could go a little more into detail on this because im not fully understand how to do it,
i dont know where to place all the functions that you and @MattPrograms made
i dont know what to assign to what
etc
xZylter
(xZylter)
November 23, 2020, 8:28pm
#26
The function I provided was just used to position the nodes that the pets should use to follow the player. Basically you should call the function whenever a player changes the number of pets they have equipped to fit for the required amount of pets.
1 Like
so how do i position the pets in the right place, as i said, it just makes a small part that follows the player
xZylter
(xZylter)
November 23, 2020, 9:34pm
#28
I was explaining that here. Make the pets AlignPosition and AlignOrientation be set to follow one of the nodes (aka the parts that my function was creating).
The code I posted was used to create the nodes for the pets to follow so you would need to use your AlignPostion and AlignOrientation code snippets and assign each pet to one of those nodes.
local alignPos = Instance.new("AlignPosition")
alignPos.MaxForce = 25000
alignPos.Attachment0 = attachPet
alignPos.Attachment1 = attachChar --Instead of attaching to the character have it attach to one of the nodes
alignPos.Responsiveness = 10
alignPos.Parent = clone
local alignOr = Instance.neâŚ
i did do that,
with the pet unachored it just falls out of the map and with it anchored it doesnât do anything
xZylter
(xZylter)
November 23, 2020, 9:40pm
#30
What are the current properties of your AlignPosition? Since if they are to weak itâs going to cause issues. I would also recommend making the pets massless.
25000 max force
massless anchored or massless unanchored?
also another question iâve been meaning to ask is what is overlap multiplier and do i use the script that @MattPrograms made in this, if so where
xZylter
(xZylter)
November 23, 2020, 9:56pm
#33
The OverlapMultiplier
was a parameter to change the radius of the circle in which the nodes were generated. It was there to give some wiggle room depending on how big your pets are.
I think the issue is that you keep trying to do local node = setPetNodes(amountEquipped, 1)
which is flawed since my function doesnât return any value as it stands right now. If you would want this to work you would need to modify my function to add add each node in the for loop to a table and return that at the end of the function.
i see, so how could i do this without having to modify your function (the for loop returning)
xZylter
(xZylter)
November 23, 2020, 10:01pm
#35
It would be a messier approach but all of the Node Parts are parented in the Playerâs Character. It would not be an ideal approach. If you want like I can modify the function to return the table of nodes.
RareFeeling
(jakemate56)
November 23, 2020, 10:03pm
#36
ok i would appreciate that, this whole thing has me confused
xZylter
(xZylter)
November 23, 2020, 10:06pm
#37
Now when using this function itâs going to return a table so when assigning pets to each node you will need to iterate over the table to assign each to pet to one of the nodes.
local function setPetNodes(petCount,overlapMultipler)
local rotationOffset = 360/petCount --Determine how much degrees must be seperated between pets
local = nodeTable = {}
for petNode = 1,petCount do
local currentNode = Instance.new("Part")
currentNode.Name = "Pet Node "..petNode
currentNode.Size = Vector3.new(1,1,1)
currentNode.CFrame = CFrame.Angles(0,math.rad(rotationOffset*petNode),0) * CFrame.new(-game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector*math.max(petCount*overlapMultipler,4)) * game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
local weld = Instance.new("WeldConstraint")
weld.Parent = currentNode
weld.Part0 = game.Players.LocalPlayer.Character.HumanoidRootPart
weld.Part1 = currentNode
currentNode.Parent = game.Players.LocalPlayer.Character
table.insert(nodeTable,currentNode)
end
return nodeTable
end
RareFeeling
(jakemate56)
November 23, 2020, 10:08pm
#38
i have my pets inside the character, should i make a folder in them so i can loop through it
xZylter
(xZylter)
November 23, 2020, 10:12pm
#39
Itâs up to you to decide that. My code was just example code to plan out your approach to the problem. Make it how you want it to work.
RareFeeling
(jakemate56)
November 23, 2020, 10:31pm
#40
alr iâll make sure to test that out
RareFeeling
(jakemate56)
November 24, 2020, 12:06am
#41
i did
local function setupPet(clone)
local node = setPetNodes(amountEquipped, 1)
for i, v in pairs(player.Character.EquippedPets:GetChildren()) do
v:SetPrimaryPartCFrame(node[i].CFrame)
end
local attachChar = Instance.new("Attachment")
attachChar.Visible = false
attachChar.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
local pos = Vector3.new(.5,.5,0) + clone.PrimaryPart.Size
attachChar.Position = pos
local attachPet = Instance.new("Attachment")
attachPet.Visible = false
attachPet.Parent = clone.PrimaryPart
local alignPos = Instance.new("AlignPosition")
alignPos.MaxForce = 25000
alignPos.Attachment0 = attachPet
alignPos.Attachment1 = node[amountEquipped]
alignPos.Responsiveness = 10
alignPos.Parent = clone
local alignOr = Instance.new("AlignOrientation", clone)
alignOr.MaxTorque = 25000
alignOr.Attachment0 = attachPet
alignOr.Attachment1 = node[amountEquipped]
alignOr.Responsiveness = 10
end
and got an error " [Expected Attachment got Part for AlignPosition:Attachment1."
well i fixed the attachment thing now the problem is the pet getting sent too far but it works completely fine other than that
local function setPetNodes(petCount,overlapMultipler)
local rotationOffset = 360/petCount --Determine how much degrees must be seperated between pets
local nodeTable = {}
for petNode = 1,petCount do
local currentNode = Instance.new("Part")
currentNode.Transparency = 1
currentNode.CanCollide = false
currentNode.Name = "Pet Node "..petNode
currentNode.Size = Vector3.new(1,1,1)
currentNode.CFrame = CFrame.Angles(0,math.rad(rotationOffset*petNode),0) * CFrame.new(-game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector*math.max(petCount*overlapMultipler,4)) * game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
local weld = Instance.new("WeldConstraint")
weld.Parent = currentNode
weld.Part0 = game.Players.LocalPlayer.Character.HumanoidRootPart
weld.Part1 = currentNode
currentNode.Parent = game.Players.LocalPlayer.Character
table.insert(nodeTable,currentNode)
end
return nodeTable
end
local function setupPet(clone)
for i, v in pairs(player.Character.EquippedPets:GetChildren()) do
local node = setPetNodes(amountEquipped, 1)
local attachNode = Instance.new("Attachment")
attachNode.Name = "AttachNode"
attachNode.Visible = false
attachNode.Parent = node[i]
attachNode.Position = node[i].Position
local attachPet = Instance.new("Attachment")
attachPet.Name = "AttachPet"
attachPet.Visible = false
attachPet.Parent = clone.PrimaryPart
local alignPos = Instance.new("AlignPosition")
alignPos.Name = "AlignPos"
alignPos.MaxForce = 25000
alignPos.Attachment0 = attachPet
alignPos.Attachment1 = attachNode
alignPos.Responsiveness = 10
alignPos.Parent = clone
local alignOr = Instance.new("AlignOrientation", clone)
alignOr.Name = "AlignOr"
alignOr.MaxTorque = 25000
alignOr.Attachment0 = attachPet
alignOr.Attachment1 = attachNode
alignOr.Responsiveness = 10
end
end
1 Like