Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How I can use CFrame in my model?

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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

0
Thanks! Its really work :D mishutapok 2 — 2y
Ad

Answer this question