Why is the TextLabel not showing the Ammo?
I am scripting a SubMachineGun.
First I have these values inside of Replicated Storage:
SMGAmmoLeft, The ammo left in the SMG
SMGEquipped, Whether the SMG is equipped.
I also have a Remote Event called FiringSMGEvent.
I have this Local Script inside of a gun tool in Starter Pack.
01 | local gun = scriptt.Parent |
02 | local ReplicatedStorage = game:GetService( 'ReplicatedStorage' ) |
03 | local remoteEvent = ReplicatedStorage:WaitForChild( 'FiringSniperEvent' ) |
06 | local EquipValue = ReplicatedStorage.EquippedSMG.Value |
08 | local player = game.Players.LocalPlayer |
09 | local mouse = player:GetMouse() |
11 | gun.Equipped:Connect( function () |
15 | mouseConnection = mouse.Button 1 Down:Connect( function () |
17 | while shooting and equipped do |
18 | remoteEvent:FireServer(gun.Handle.Position, gun.Handle.Orientation, mouse.Hit.p) |
20 | game.ReplicatedStorage.SMGAmmo.Value- = 1 |
21 | if gun.Ammo.Value = = 0 then |
23 | game.ReplicatedStorage.SMGAmmo.Value = 0 |
26 | game.ReplicatedStorage.SMGAmmo.Value = 50 |
29 | mouse.Button 1 Up:Connect( function () |
39 | gun.Unequipped:Connect( function () |
41 | mouseConnection:Disconnect() |
I have this Local Script inside of a ScreenGui which is home to a TextLabel which is supposed to display the ammo left.
01 | script.Parent.TextLabel.Visible = false |
02 | game.ReplicatedStorage.EquippedSMG.Changed:Connect( function () |
03 | if game.ReplicatedStorage.EquippedSMG = = true then |
04 | script.Parent.TextLabel.Visible = true |
05 | script.Parent.TextLabel.Text = game.ReplicatedStorage.SMGAmmo.Value |
06 | elseif game.ReplicatedStorage.EquippedSMG = = false then |
07 | script.Parent.TextLabel.Visible = false |
The TextLabel is not displaying the AmmoLeft.
May you please help me?