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

How to make it so a PlayerGui Text is the same as a SurfaceGui's text?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make it so the PlayerGui TextLabel says 4 and SurfaceGui TextLabel says 4 i shoot the gun the PlayerGui text turns into 3 and the SurfaceGui's TextLabel changes to 3 as well and know that im not that good at scripting and im using the Template Assault Rifle script. I tried it and i get this error

02:30:07.736 - WeaponHud is not a valid member of PlayerGui

local Player = game.Players.LocalPlayer
local GUI = Player.PlayerGui
local ClipAmmo = GUI.WeaponHud.AmmoHud.ClipAmmo
local TextLabel = script.Parent

GUI:WaitforChild("AmmoHud")

while true do
TextLabel.Text = ClipAmmo   
end
0
use remotevnts Lolamtic 63 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

you are setting the textlabels text to the clipammo, not the clipammo text.

local Player = game.Players.LocalPlayer
local GUI = Player.PlayerGui
local ClipAmmo = GUI.WeaponHud.AmmoHud.ClipAmmo.Text
local TextLabel = script.Parent

GUI:WaitforChild("AmmoHud")

while true do
TextLabel.Text = ClipAmmo   
end
0
I still got the same error 03:32:48.474 - WeaponHud is not a valid member of PlayerGui HistoricalCletus2005 2 — 5y
0
do :WaitForChild for the weaponhud, like this. local ClipAmmo = GUI:WaitForChild("WeaponHud").AmmoHud.ClipAmmo.Text ieatandisbaconhair 77 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

-- This will need to be in local script local Player = game.Players.LocalPlayer local GUI = Player.PlayerGui local ClipAmmo = GUI.WeaponHud.AmmoHud.ClipAmmo.Text local TextLabel = script.Parent GUI:WaitforChild("AmmoHud") while true do TextLabel.Text = ClipAmmo end

If still not working:

-- This will need to be in local script


local Player = game.Players.LocalPlayer
local GUI = game:GetService("StarterGui")
local ClipAmmo = GUI.WeaponHud.AmmoHud.ClipAmmo.Text
local TextLabel = script.Parent

GUI:WaitforChild("AmmoHud")

while true do
TextLabel.Text = ClipAmmo   
end

AND IF STILL NOT WORKING

-- This will need to be in local script


local Player = game.Players.LocalPlayer
local GUI = game:GetService("PlayerGui")
local ClipAmmo = GUI.WeaponHud.AmmoHud.ClipAmmo.Text
local TextLabel = script.Parent

GUI:WaitforChild("AmmoHud")

while true do
TextLabel.Text = ClipAmmo   
end
0
04:06:05.191 - Players.HistoricalCletus2005.Backpack.Assault RIfle.Union.Number.SurfaceGui.TextLabel.LocalScript:3: attempt to index local 'GUI' (a nil value) HistoricalCletus2005 2 — 5y
0
Hmm.. I don't know, There is something in the gun I think. Starnamics 24 — 5y
0
Maybe start another question, because that error doesn't look to be related to the script itself. Starnamics 24 — 5y
0
Do not do this; the infinite while loop will hang and crash the script. RayCurse 1518 — 5y

Answer this question