I'm trying to make it so that when you toggle the camera side, the tool switches over to the other hand closest to the center of the camera. When I equip it, though, both of the animations play at the same time and when I unequip it, they don't stop when I tell it to. No errors in the output window. Here's what I have:
Camera local script in starter character scripts:
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton3 then
if cameraOffset == Vector3.new(2, 2, 5) then
for i = 0,4 do
cameraOffset = Vector3.new(2-(1*i), 2, 5)
ToggleLeft:FireServer()
wait()
end
else
for i = 0,4 do
cameraOffset = Vector3.new(-2+(1*i), 2, 5)
ToggleRight:FireServer()
wait()
end
end
end
end)
The local script inside of the tool:
function OnEquipped()
EquipAnim:FireServer()
end
function OnUnequipped()
UnequipAnim:FireServer()
end
Tool.Equipped:Connect(OnEquipped)
Tool.Unequipped:Connect(OnUnequipped)
Server script inside of the tool:
EquipAnim.OnServerEvent:Connect(function(plr)
if Tool.Right.Value == true then
Tool.Right.Value = false
Tool.Left.Value = true
local LeftAnim = plr.Character.Humanoid:LoadAnimation(Tool.LeftAnim)
local RightAnim = plr.Character.Humanoid:LoadAnimation(Tool.RightAnim)
LeftAnim:Play()
if RightAnim.IsPlaying then
RightAnim:Stop()
end
end
if Tool.Left.Value == true then
Tool.Left.Value = false
Tool.Right.Value = true
local LeftAnim = plr.Character.Humanoid:LoadAnimation(Tool.LeftAnim)
local RightAnim = plr.Character.Humanoid:LoadAnimation(Tool.RightAnim)
RightAnim:Play()
if LeftAnim.IsPlaying then
LeftAnim:Stop()
end
end
end)
ToggleLeft.OnServerEvent:Connect(function(plr)
if Tool.Right.Value == true then
Tool.Right.Value = false
Tool.Left.Value = true
local LeftAnim = plr.Character.Humanoid:LoadAnimation(Tool.LeftAnim)
local RightAnim = plr.Character.Humanoid:LoadAnimation(Tool.RightAnim)
LeftAnim:Play()
if RightAnim.IsPlaying then
RightAnim:Stop()
end
end
end)
ToggleRight.OnServerEvent:Connect(function(plr)
if Tool.Left.Value == true then
Tool.Left.Value = false
Tool.Right.Value = true
local LeftAnim = plr.Character.Humanoid:LoadAnimation(Tool.LeftAnim)
local RightAnim = plr.Character.Humanoid:LoadAnimation(Tool.RightAnim)
RightAnim:Play()
if LeftAnim.IsPlaying then
LeftAnim:Stop()
end
end
end)
UnequipAnim.OnServerEvent:Connect(function(plr)
local LeftAnim = plr.Character.Humanoid:LoadAnimation(Tool.LeftAnim)
local RightAnim = plr.Character.Humanoid:LoadAnimation(Tool.RightAnim)
if LeftAnim.IsPlaying then
LeftAnim:Stop()
end
if RightAnim.IsPlaying then
RightAnim:Stop()
end
end)
Any help is appreciated, thanks for your time in advance.
