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

This makes both Camera.Changed functions go off?

Asked by 10 years ago

I'm trying to make it so that when the player has the Tool AK-47 selected Move the Rightshoulder and neck at the same time and when deselected have only the Neck move at once instead of both Right shoulder and neck. But instead it makes both the Camera.Changed:connect(function()'s go off at the same time when I have the gun selected.

local Camera = game.Workspace.CurrentCamera
local human = game.Players.LocalPlayer.Character
while true do
if game.Players.LocalPlayer.Backpack:FindFirstChild("AK-47") then
Camera.Changed:connect(function()
    human.Torso.Neck.C1 = CFrame.new();
    human.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin(Camera.CoordinateFrame.lookVector.Y), 0, 0);
    human.Torso["Right Shoulder"].C0 = CFrame.new(1, 0.5, 0) *CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
end)
elseif game.Players.LocalPlayer.Character:FindFirstChild("AK-47") then
    human.Torso.Neck.C1 = CFrame.new();
    human.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin(Camera.CoordinateFrame.lookVector.Y), 0, 0);
    human.Torso["Right Shoulder"].C0 = CFrame.new(0.5, 0.5, 0.5) *CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))* CFrame.Angles(0, 0, math.asin(Camera.CoordinateFrame.lookVector.Y));
end
wait()
end
1
There is only one Camera.Changed event connection in the code that you posted. duckwit 1404 — 10y

Answer this question