So I'm trying to make the bar scroll to the amount left in the gun but nothing is happening

someone wanted the full script, so: (look at the reload section)

----------------------------------------------------------------------------
repeat wait() until game.Players.LocalPlayer
globmod = require(script.GlobalRuns)
local tool 				= script.Parent
local handle 			= script.Parent.shoota
local shooter 			= tool.shoota
local mouse 			= game.Players.LocalPlayer:GetMouse()
local player 			= game.Players.LocalPlayer
local Character 		= player.Character
local mousedown 		= false
local bulletvelocity 	= 150
local betweenshot 		= .18
local currentamount		= 12 --the one below should be the same ammount
local afterreload		= 12
local maxammo 			= 144 --again same as below
local currentmax 		= 144 
local emit 				= true
local dmgmin			= 10
local dmgmax			= 15
local contextAction 	= game:GetService("ContextActionService")
local reloading         = false
local amIreloading 		= false
local running 			= false
----------------------------------------------------------------------------
local enabled = false
game.Players.LocalPlayer.Character.Humanoid.Running:connect(function(speed)
	if enabled == true then
		if speed > 6 then
			running = true
			print("running")
		else
			print("notrunning")
			running = false
		end
	end
end)

script.Parent.Equipped:connect(function()
	enabled = true
	local clonegui 		= script.Parent.ToolGui:Clone()
	clonegui.Parent 	= game.Players.LocalPlayer.PlayerGui
	ammotext 			= clonegui.GunFrame.AmmoAmount
	ammoimage			= clonegui.GunFrame.ImageLabel
	ammotext.Text 		= currentamount
	local sound 		= script.Parent.Handle.Sound
	script.Parent.Unequipped:connect(function()
		clonegui:Destroy()
		enabled = false
	end)
end)
local scrollmax	= game.Players.LocalPlayer.PlayerGui.ToolGui.GunFrame.AmmoAmount.Background.TextLabel
-------------------------- mousedown manager ------------------------------
mouse.Button1Down:connect(function()
	mousedown = true
end)
mouse.Button1Up:connect(function()
	mousedown = false
end)

--------------------------------particleemitter maker----------------------------------

local emit = function(part)
	local emitter = Instance.new("ParticleEmitter", part)
	emitter.EmissionDirection = Enum.NormalId.Back
	emitter.Size = NumberSequence.new(10)
	emitter.Transparency = NumberSequence.new(0.4,0.7)
	emitter.Texture = "http://www.roblox.com/asset/?id=241685484"
	emitter.Speed = NumberRange.new(0)
	emitter.Acceleration = part.CFrame:inverse().p
	emitter.Lifetime = NumberRange.new(.1)
	emitter.Rate = 50
	emitter.Color = ColorSequence.new(Color3.new(0,0,255), Color3.new(255,255,255))
end

------------------------------ welding ------------------------------------
local Weld = function(x, y)
	local W = Instance.new("Weld")
	W.Part0 = x
	W.Part1 = y
	local CJ = CFrame.new(x.Position)
	local C0 = x.CFrame:inverse()* CJ
	local C1 = y.CFrame:inverse()* CJ
	W.C0 = C0
	W.C1 = C1
	W.Parent = x
end
---------------------------------------------------------------------------

Weld(handle, shooter)
function checkifplayer(hit)
	if tostring(hit:GetFullName()):match(player.Name) then
		return true
	else
		return false
	end
end


--------------------------------- reload ---------------------------------
function reload()
	if amIreloading == false then
		amIreloading = true
		ammotext.Text = "      Reload      "
		scrollmax.BorderColor3 = Color3.new(255/255,0,0)
		scrollmax.Size = UDim2.new(currentmax/maxammo,0,scrollmax.Size.Y.Scale,0)
		scrollmax.BorderColor3 = Color3.new(255/255,255/255,255/255)
		wait(2)
		amIreloading = false
		currentamount = afterreload
		ammotext.Text = currentamount
	else
		print("holdingmouseclick")
	end
end
------------------------------ bullet script ------------------------------
local shootbullet = function(startpos, endpos)

	local magnitude         = (startpos - endpos).magnitude
	local part 				= Instance.new("Part")
	if emit == true then emit(part) end
	part.Anchored 			= false
	part.CanCollide 		= false
	part.CFrame 			= shooter.CFrame
	part.BrickColor			= BrickColor.new("Bright yellow")
	part.FormFactor 		= Enum.FormFactor.Custom
	part.Size 				= Vector3.new(0.1,0.1,0.1)
	part.TopSurface 		= Enum.SurfaceType.SmoothNoOutlines
	part.BottomSurface 		= Enum.SurfaceType.SmoothNoOutlines
	part.Transparency = 1
	
		spawn(function() script.Parent.shoota.BillboardGui.ImageLabel.ImageTransparency = 0 wait(.05) script.Parent.shoota.BillboardGui.ImageLabel.ImageTransparency = 1 end)
	
		local bodyForce = Instance.new('BodyForce', part)
		bodyForce.Name = 'Antigravity'
		bodyForce.force = Vector3.new(0, part:GetMass() * 196.8 - .12, 0)

		local spawnPosition = (handle.CFrame * CFrame.new(0, 0, 0)).p
		part.CFrame = CFrame.new(spawnPosition, mouse.Hit.p) 
	
		part.Velocity = part.CFrame.lookVector * bulletvelocity
		part.Parent = workspace
		
		return part	
end
---------------------------------ammo function-------------------------------------------------

function assumeLargerPosition()
	ammotext.TextColor3 = Color3.new(1,1,1)
	ammoimage.ImageColor3 = Color3.new(1,1,1)
	ammotext:TweenSizeAndPosition(UDim2.new(0.1, 0,0.06, 0),UDim2.new(0.88, 0,0.905, 0),"Out","Quad",1/30, true) ammoimage:TweenSizeAndPosition(UDim2.new(0.07, 0,0.07, 0),UDim2.new(0.904, 0,0.847, 0),"Out","Quad",1/30, true)
end

function assumeSmallerPosition(times)
	ammotext.TextColor3 = Color3.new(175/255,175/255,175/255)
	ammoimage.ImageColor3 = Color3.new(200/255,200/255,200/255)
	ammoimage:TweenSizeAndPosition(UDim2.new(0.05, 0,0.05, 0),UDim2.new(0.912, 0,0.866, 0),"Out","Quad",times, true) ammotext:TweenSizeAndPosition(UDim2.new(0.1, 0,0.04, 0),UDim2.new(0.88, 0,0.915, 0),"Out","Quad",times, true)
	
end

function shootgui()
	assumeLargerPosition()
	wait(betweenshot*3)
	assumeSmallerPosition(betweenshot*3)
end

function updateammo()
	ammotext.Text = currentamount
end

function CheckAmmo()
	if currentamount == 1 or currentamount < 1 then
		assumeSmallerPosition()
		reload()
		amIreloading = false
		return false
	else
		return true
	end	
end

---------------------------------shoot function------------------------------------------------

local clickdeb = true

mouse.Button1Down:connect(function()
	if clickdeb then
		clickdeb = false
		if CheckAmmo() then
			currentamount = currentamount - 1
			spawn(function() updateammo() wait(.2) shootgui() end)
			local bullet = shootbullet(shooter.CFrame.p, mouse.Hit.p)
			local damage = math.random(dmgmin,dmgmax)
			bullet.Touched:connect(function(hit)
				if hit.Name == "Head" then damage = damage * 3 end
				globmod:hurt(hit.Parent,damage)
				bullet:Destroy()
			end)
		end
		wait(betweenshot)
		clickdeb = true
	end
end)



--------------------------------- Binding ---------------------------------

contextAction:BindAction("openDoor", openDoorFunction, false, Enum.KeyCode.ButtonX)

2 comments

0

What is GlobelRuns?

0

a module