I cant bring the pet to the player

hello, basically I have no idea on how to fix in place 2 parts fully and bring them to person, Union makes it look weird and idk how to do it with model

here is the script

local rs = game:GetService("ReplicatedStorage")

rs.specialrocks["pet-e"].OnServerEvent:Connect(function(plr, tool)
	local pet = game.ServerStorage.abilities.petability
	local char = plr.Character
	local humrootpart = char:FindFirstChild("HumanoidRootPart")
	local clonedpet = pet:Clone()
	clonedpet.petability.BrickColor = BrickColor.new("Bright blue")
	clonedpet.petability.CanCollide = false
	clonedpet.petability.Parent = char
	clonedpet.petability.CFrame = humrootpart.CFrame * CFrame.new(-2, -2, 3)

	local weld = Instance.new("WeldConstraint")
	weld.Parent = clonedpet.petability
	weld.Part0 = humrootpart
	weld.Part1 = clonedpet.petability
	
	tool:SetAttribute("damage", (tool:GetAttribute("damage") + 20))
	tool:SetAttribute("power", (tool:GetAttribute("power") + 50))
	
	task.wait(3)
	
	clonedpet:Destroy()
	tool:SetAttribute("damage",(tool:GetAttribute("damage") - 20))
	tool:SetAttribute("power", (tool:GetAttribute("damage") - 50))
end)

thanks

1 Like

I am not 100% sure if you mean this. If this is not where you are looking for, please explain further.

1 Like

no, basically i want the model (that is made out of 2 blocks) work in this script, union not works because it breaks it and with model i dont know how to make

1 Like

You can use :PivotTo(), takes in a CFrame to position a model

1 Like

bruh i forgot about that function, thanks i will try that

1 Like

i tried it and it gave new error

local rs = game:GetService("ReplicatedStorage")

rs.specialrocks["pet-e"].OnServerEvent:Connect(function(plr, tool)
	local pet = game.ServerStorage.abilities.petability
	local char = plr.Character
	local humrootpart = char:FindFirstChild("HumanoidRootPart")
	local clonedpet = pet:Clone()
	clonedpet.petability.BrickColor = BrickColor.new("Bright blue")
	clonedpet.petability.CanCollide = false
	clonedpet.petability.Parent = char
	clonedpet:PivotTo(humrootpart.CFrame * CFrame.new(-2, -2, 3))

	local weld = Instance.new("WeldConstraint")
	weld.Parent = clonedpet.petability
	weld.Part0 = humrootpart
	weld.Part1 = clonedpet.petability
	
	tool:SetAttribute("damage", (tool:GetAttribute("damage") + 20))
	tool:SetAttribute("power", (tool:GetAttribute("power") + 50))
	
	task.wait(3)
	
	clonedpet:Destroy()
	tool:SetAttribute("damage",(tool:GetAttribute("damage") - 20))
	tool:SetAttribute("power", (tool:GetAttribute("damage") - 50))
end)

error: petability is not a valid member of Model “petability” - Server - pet:14

1 Like

You are moving petability into the character

clonedpet.petability.Parent = char
and after that
weld.Parent = clonedpet.petability

To index your petability, char.petability

so whats the problem? i didnt really understand what you meant
oops i realized sorry for taking your time

1 Like

so i fixed it and now it just makes me spin when i turn rly strangely
and no errors

Make sure that every part in your pet model is massless as this interferes with the actual character.

no, sorry i forgot to mention but pet also doesnt appear

nevermind i fixed it myself, quite stupid problem tbh but ok

You could also just position the pet with an offset, based on the characters’ PrimaryPart position

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