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

How do i get my text GUI to update properly?

I checked through the website and all of the results i wanted didnt help fix my issue so i am now asking for help. I am having an issue with a gui changing script where the printing works properly but hte GUI doesnt update at all. the code is:

--instances
local Player = game:GetService("Players").LocalPlayer
local Text = script.Parent.Text
local Color = script.Parent.TextColor
local Textchange = script.Parent.TextChange
--functions
local function SetText(Ammo, Ammocap)
	print(Ammo.."/"..Ammocap)
	print("before if argument")
	if Ammo / Ammocap < 1.5 then
		Color = Color3.new(0.807843, 0, 0)
		print("in if argument")
	end
	print("after if argument")
	Text = Ammo.."/"..Ammocap
end

--function connects
Textchange.Event:Connect(function(Ammo, Ammocap)
	print("triggered Bindable Event")
	SetText(Ammo, Ammocap)
end)

alos i am certain that all of my instances are correct, hte text just doesnt update correctly

4 comments

0

just so everyone knows all of the prints are to check bugs

0

just so everyone knows all of the prints are to check bugs

0

The names of the instances are properties and the script will get confused

0

what do you mean the script will get confused? the Ammo and Ammocap are numbers all the time so it should work

1 answer

I would recommend testing if tostring() works. I'm assuming Ammo and Ammocap are ints, meaning when you try to append a string to them it doesn't automatically change them. So test if this works on line 15: Text= tostring(Ammo).."/"..tostring(Ammocap), if it does please mark this as the answer, otherwise comment on this if there's an error or anything! Good Luck

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