I’ve tried this with the F key and it has worked, now i just need to make it work with RightClick, I’ve been experimenting with it to make it work but it’s not.
Code:
`wait(2)
local player = game.Players.LocalPlayer
local Character = player.Character or player.Character:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local mouse = player:GetMouse()
local block = game:GetService("ReplicatedStorage").Block
local Sword_Block_Animation = Instance.new("Animation")
Sword_Block_Animation.AnimationId = "rbxassetid://9404434731"
local AnimationTrackBlock = Humanoid.Animator:LoadAnimation(Sword_Block_Animation)
mouse.Button2Down:Connect(function(input,inchat)
if inchat then
elseif input.Button2Down == mouse.Button2Down then
local Anim = script.Block
AnimationTrackBlock:Play()
block:FireServer()
end
end)
mouse.Button2Up:Connect(function(input,inchat)
if inchat then
elseif input.Button2Up == mouse.Button2Up then
AnimationTrackBlock:Stop()
block:FireServer()
end
end)
Humanoid.block.Changed:Connect(function()
if Humanoid.block.Value == false then
AnimationTrackBlock:Stop()
end
end)
`
Errors:
Workspace.WaterCanxiety.Scimitar.Block:17: attempt to index nil with 'Button2Down'
and
Workspace.WaterCanxiety.Scimitar.Block:26: attempt to index nil with 'Button2Up'