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

My viewmodel is making character's head act as if it is anchored. What's wrong?

Asked by 7 years ago
Edited 7 years ago

I'm making an animated viewmodel for a first person shooter and I'm having some issues. When I equip the tool, a LocalScript clones the model, welds it to the player's head, and puts it into CurrentCamera; everything here works fine, but there is one problem. The player falls to its torso and it acts as if it head is welded. I checked to make sure none of the parts are anchored and the head is not anchored either.

Here is a screenshot of the problem:

imgur.com/a/0IPt6

Here is the script in the tool:

script.Parent.Equipped:connect(function()
    local knife = game.ReplicatedStorage.kniferig:Clone()
    local weld = Instance.new("Weld", knife.HumanoidRootPart)
    weld.Part0 = knife.HumanoidRootPart
    weld.Part1 = game.Players.LocalPlayer.Character.Head
    weld.C0 = CFrame.new(0,1.5,0)
    knife.Parent = game.Workspace.CurrentCamera
end)
script.Parent.Unequipped:connect(function()
    for _,x in pairs(game.Workspace.CurrentCamera:GetChildren()) do
        x:Destroy()
    end
end)

Here is another LocalScript that points the character's head to the player's mouse:

game:GetService("RunService").RenderStepped:connect(function()
    game.Players.LocalPlayer.Character.Torso.Neck.C1 = CFrame.new()
    game.Players.LocalPlayer.Character.Torso.Neck.C0 = CFrame.new(0,1.5,0) * CFrame.Angles(math.asin((game.Players.LocalPlayer:GetMouse().Hit.p).unit.y), 0, 0)
end)
0
Anyone? smartlegomaniac 0 — 7y

Answer this question