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

2 Likes

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

3 Likes

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

3 Likes

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

3 Likes

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

3 Likes

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

2 Likes

You are moving petability into the character

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

To index your petability, char.petability

1 Like

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

2 Likes

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

1 Like

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

1 Like

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

1 Like

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

1 Like

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

1 Like

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