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

How I can use CFrame in my model?

Hi guys! What is the correct way to use CFrame in a model? I've searched different forums and they talk about Primary Part and in the SetPrimaryPartCFrame code. But the problem is that when you kill an animal, the meat falls off it. But no matter how I tried to do it, I failed. Could you please help me with this?

local Model = script.Parent
local Humanoid = Model.Humanoid
local Torso = Model.Torso
local WalkAnim = Humanoid:LoadAnimation(Humanoid.WalkAnim)

local Meat = game.Workspace.Mechanics.Food.Meat
local meatSet = game.Workspace.Mechanics.Food.Meat.Meat

local drop = script.Parent.HumanoidRootPart.CFrame

Humanoid.Died:Connect(function(plr)
	Meat:SetPrimaryPartCFrame(meatSet.CFrame * CFrame.new(drop))
	
	task.wait(3)
	script.Parent:ClearAllChildren()
end)

while true do
	wait(math.random(1,6))
	WalkAnim:Play()
	Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-16, 16), 0, math.random(-16, 16)))
	Humanoid.MoveToFinished:Connect(function()
		WalkAnim:Stop()
	end)
end

1 answer

✓ Accepted answer

Meat:SetPrimaryPartCFrame(meatSet.CFrame * CFrame.new(drop))

from SetPrimaryPartCFrame, you can directly go to drop. and because its already a cframe value, you don't need to use cframe.new.

change the line above to Meat:SetPrimaryPartCFrame(drop) and it should work

1 comment

0

Thanks! Its really work :D

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