Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

use remotevnts

2 answers

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

2 comments

0

I still got the same error 03:32:48.474 - WeaponHud is not a valid member of PlayerGui

0

do :WaitForChild for the weaponhud, like this. local ClipAmmo = GUI:WaitForChild("WeaponHud").AmmoHud.ClipAmmo.Text


-- 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

4 comments

0

04:06:05.191 - Players.HistoricalCletus2005.Backpack.Assault RIfle.Union.Number.SurfaceGui.TextLabel.LocalScript:3: attempt to index local 'GUI' (a nil value)

0

Hmm.. I don't know, There is something in the gun I think.

0

Maybe start another question, because that error doesn't look to be related to the script itself.

0

Do not do this; the infinite while loop will hang and crash the script.

This discussion is preserved as it was. New answers, comments, and votes are closed.