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

Why is this lookVector not working properly?

Asked by
DevingDev 346 Moderation Voter
5 years ago
Edited 5 years ago

I'm trying to tween a model to a few studs in front of a part but for some reason it tweens to around 0,0,0 and not my near the parts position at all.

Hers my script:

local function TweenModel(NPC, cframe)
    local TweenService = game:GetService("TweenService")
    local TweenInfo = TweenInfo.new(0.7, Enum.EasingStyle.Bounce)

    local Tween = TweenService:Create(NPC.PrimaryPart, TweenInfo, {CFrame = cframe})
    Tween:Play()
end

local function InitNPC(NPC)
    local Data = ClientStatCache:Get()
    local Tool = Data["Tool"]

    local ToolModel = Player.Character:FindFirstChild(Tool)
    local Offset = ToolModel.Model:FindFirstChild("Offset")

    local HumanoidRootPart = NPC:FindFirstChild("HumanoidRootPart")
    HumanoidRootPart.Anchored = true

    local cframe = CFrame.new(Offset.CFrame.lookVector.Unit * 5)

    TweenModel(NPC, cframe)
end

Answer this question