Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How Do I make This Gun Reload By Clicking instead of hitting r?

I can script but i for sure am not this good at it.. and my friend gave me this script but I think he copied it but he said he made it but anyway how do you make it to where it reloads from clicking instead of hitting R..

function onButton1Up(mouse)

automatichold = false

end

  

function onKeyDown(key, mouse)

  

  

  

if key:lower() == "r" then

if script.Parent.Ammo.Value ~= script.Parent.MaxAmmo.Value then

reloadsound = script.Parent.Handle:FindFirstChild("Reload")

if reloadsound then

reloadsound:Play()

end

enabled = false

script.Parent.VisibleB.Value = true

script.Parent.StringValue.Value = "Reloading"

repeat script.Parent.StringValue.Value = "Reloading" wait(0.3) script.Parent.Ammo.Value = script.Parent.Ammo.Value + 3 script.Parent.StringValue.Value = "Reloading" until script.Parent.Ammo.Value >= script.Parent.MaxAmmo.Value

script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value

wait(0.2)

script.Parent.VisibleB.Value = false

enabled = true

end

end

  

if key:lower() == "m" then

if GunType == 0 then

GunType = 0

Recoil = 3

else

GunType = 1

Recoil = 3

end

end

  

end

function onEquipped(mouse)

equipped = true

  

if mouse == nil then

print("Mouse not found")

return

end

mouse.Icon = "http://www.roblox.com/asset/?id=52812029"

mouse.Button1Down:connect(function() onButton1Down(mouse) end)

mouse.Button1Up:connect(function() onButton1Up(mouse) end)

mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)

  

end

  

function onUnequipped(mouse)

equipped = false

automatichold = false

  

  

end

  

script.Parent.Equipped:connect(onEquipped)

script.Parent.Unequipped:connect(onUnequipped)

while true do wait()

if script.Parent.Ammo.Value == 0 then

script.Parent.VisibleB.Value = true

script.Parent.StringValue.Value = "Reload"

end

if GunType == 1 then

script.Parent.ModeText.Value = "Auto"

else

script.Parent.ModeText.Value = "Semi"

end

end

4 comments

0

Just check if it dosent have ammo and you click

0

Ik that but can you provide the script and how to correct the script in the answer section please and thank you so much

0

Hm

0

did you just use it as a free model? Cus if u didn't, you would be able to figure that out

1 answer

Assuming you are using the :GetMouse() you can use the event .Button1Down(). This fires when the player clicks down Left Mouse Button. Similarly with .Button2Down() when the player clicks down Right Mouse Button.

2 comments

0

As said I suck so could you possibly like add it into the script I gave? And help more thanks :)

0

This isn't a requests site. We just give you the answers.

This discussion is preserved as it was. New answers, comments, and votes are closed.