Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the TextLabel not showing the Ammo?

Asked by 3 years ago

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.

01local gun = scriptt.Parent
02local ReplicatedStorage = game:GetService('ReplicatedStorage')
03local remoteEvent = ReplicatedStorage:WaitForChild('FiringSniperEvent')
04local shooting = false
05local equipped = false
06local EquipValue = ReplicatedStorage.EquippedSMG.Value
07EquipValue=false
08local player = game.Players.LocalPlayer
09local mouse = player:GetMouse()
10local mouseConnection
11gun.Equipped:Connect(function()
12    equipped = true
13    EquipValue=true
14    mouse.Icon = 'rbxassetid://117431027'
15    mouseConnection = mouse.Button1Down:Connect(function()
View all 42 lines...

I have this Local Script inside of a ScreenGui which is home to a TextLabel which is supposed to display the ammo left.

01script.Parent.TextLabel.Visible=false
02game.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
08    end
09 
10end)

The TextLabel is not displaying the AmmoLeft. May you please help me?

1 answer

Log in to vote
0
Answered by 3 years ago

Thats because u dont fire the event so the textlabel never recibe that information

0
So I should create a BindableEvent that will fire whenever the gun is equipped? sidb0102 17 — 3y
Ad

Answer this question