Whenever you press LMB it reloads the gun... but I only want the R button to reload the gun instead. How would I do this?
For Testing Purposes:
Make a tool and put it in starterpack.
Make a part in the tool and name it "Handle"
3)Put a RemoteEvent in the tool and name it "Damage"
localscript:
local MaxAmmo = 5
local Ammo = MaxAmmo
local Reloading = false
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Icon = "rbxasset://textures/GunCursor.png"
local function Reload()
Reloading = true
Mouse.Icon = "rbxasset://textures/GunCursor.png"
wait(2)
Ammo = MaxAmmo
Reloading = false
Mouse.Icon = "rbxasset://textures/GunCursor.png"
end
script.Parent.Activated:Connect(function()
if Ammo>0 and not Reloading then
Ammo=Ammo-1
if Mouse.Target.Parent:FindFirstChild("Humanoid") then
script.Parent.Damage:FireServer(Mouse.Target.Parent, 20)
end
elseif Reloading == false then
Reload()
end
print(Ammo)
end)
local Input = game:GetService("UserInputService")
Input.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.R and Reloading == false and Ammo~=MaxAmmo then
Reload()
end
end)
end)
serverscript:
script.Parent.Damage.OnServerEvent:Connect(function(Player, Target, Damage)
Target.Humanoid:TakeDamage(Damage)
end)

1 comment
Thanks