Been working on my game for a while, and recently got to the point where I’ve started making tools to be used in game. I’ve made the base for my gun, which right now, just plays an idle animation and sound when equipped, and stops the animation whilst playing a different sound on unequip.
I want the gun to enable an over the shoulder cam (basically, shift lock) whenever it’s equipped, and disable this cam on unequip. But I have no idea how exactly I should go about this.
Reading other forum posts wasn’t much help, since they where all either over the shoulder all the time, or outdated and overcomplicated to the point of it being unusable for me.
Any help with this is massively appreciated, thanks!
Here’s my gun’s code, if that helps at all:
local tool = script.Parent
local Equip = script.Equip -- Equip sound
local Holster = script.Holster -- Holster sound
local idle = script:FindFirstChild("Idle") -- Idle animation
local player = script.Parent.Parent.Parent
character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
tool.Equipped:Connect(function()
Equip:Play()
local idleAnimation = humanoid:LoadAnimation(idle)
idleAnimation:Play()
tool.Unequipped:Connect(function()
Holster:Play()
idleAnimation:Stop()
end)
end)