I'm currently trying to make my own Roblox gun from scratch (to test if I can), and I'm encountering a strange problem.

game.ReplicatedStorage.AmmoCtStC.OnServerInvoke = (function(player, Ammoleft)
	if Ammoleft == 0 then 
		local AmmoOut = "No Ammo Left"
		return AmmoOut
	else
		local AmmoSub = Ammoleft - 1 
		return AmmoSub
	end
end)

For some reason, the script is only ever running the else condition, even when I manually set the "Ammoleft" to 0.

Edit This is part of the local script, if you need any more information on it I can just put that in here too.

userInputService.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			if GunEquipped == true then 
				Gun_Fired:FireServer(Mouse.Hit.lookVector)
				local result = game.ReplicatedStorage.AmmoCtStC:InvokeServer(GunGui.Ammo_Cap.AmmoLeft.Text)
				GunGui.Ammo_Cap.AmmoLeft.Text = result
			end

I know some of my variables are weirdly named, just let me know if one is confusing you.

3 comments

0

=[

0

show localscript

0

I want to apologize to those who respond to me a moth ago, I forgot I had posted this on scripting helpers, and not on the roblox dev fourm, anyway I figured this out my own.