Ammo reload on Mousebutton1click is not functioning

I am making a ammo reload gun on a Function(click), however I have made a clickdetector and connected a mousebutton1click into the click detector. My script here:


game.Workspace.AmmoBasket.ClickDetector.Parent = MouseButton1Click

when game.AmmoBasket.ClickDetector.Clicked = true do

game.StarterPack.AK47.AmmoValue + 1

function(click)

game:GetService(“CollectionService”)

local CS = Game:GetService(“Value”)

CS.AmmoValue = local Value

When workspace.AmmoBasket.ClickDetector.Clicked = true then

AmmoValue + 100

I don’t know why this isn’t working, I am assuming that CollectionService is a good helper when it comes to this but I am not sure on why its not functioning.

try this

01 function reload(key)

02 key = key:lower()

03 enabled = true

04 if key = = "r" and enabled = = true and ammo < 30 then

05 enabled = false

06 repeat

07 print ( "reloading" )

08 wait( 0.1 )

09 Ammo = Ammo + 1

10 until Ammo = = MaxAmmo

11 end

12 end

When?!!! It should ve while​:sweat_smile::sweat_smile:

This is not a good practise you should use game:GetService(“RunService”). HeartBeat:Wait()