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

Ammo gui isn't working on a gun, can somebody help me with what I've done wrong?

Asked by 8 years ago

I got an ammo gui ed with a LocalScript but it aparently doesn't work :/

01local players = game:GetService("Players")
02local player = players.LocalPlayer
03local weapon = .Parent
04local ammo = .Parent:WaitForChild('CurrentAmmo').Value
05local maxammo = .Parent:WaitForChild('MaxAmmo').Value
06 
07weapon.Equipped:connect(function()
08    local gui = Instance.new('ScreenGui', player.PlayerGui)
09    gui.Name = 'WeaponGui'
10    local currentammogui = Instance.new('TextBox', gui)
11    currentammogui.Name = 'CurrentAmmo'
12    currentammogui.Text = 'Current: '..ammo
13    currentammogui.Size = UDim2.new(0.17, 0, 0.07, 0)
14    currentammogui.Position = UDim2.new(0.81, 0, 0.9, 0)
15    currentammogui.BackgroundTransparency = 1
View all 35 lines...

Photo of how my Studio looks like: http://prntscr.com/e7is61

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

When setting the initial text of currentammogui and the maxammogui, you need to index the ammo Value's Value Property.

1--line 12
2currentammogui.Text = 'Current: '..ammo.Value
3 
4--line 20
5maxammogui.Text = 'Max: '..maxammo.Value
0
It is, it just copied wrong somehow :/ VladimVladim 78 — 8y
0
I have a script to change the value, but it isn't this script :/ VladimVladim 78 — 8y
0
Alright, I think I found your error then. Edited my answer. Next time supply any errors that appear in the Output. Makes it super easy for us to fix your code. Goulstem 8144 — 8y
0
That's not the problem as look correctly at the script is says script.Parent:WaitForChild('CurrentAmmo').Value VladimVladim 78 — 8y
Ad

Answer this question