Effect Script Ui Problem

Hi, I am a new developer that is currently making a game, I am right now working on adding status effects in my game, there are two scripts I use to manage the effects, one being the script that performs actions, the second is the script that shows a Gui when that effect is on.

The first script is fine and doesn’t have any problems, but the Gui script is what I really need help with, because it doesn’t show that Gui.

I tried putting everything in one script, but it didn’t work, I do know a little about server and client, but I don’t know anything else about it other than knowing not to test with the client. The objective here for me is when that effect is turned on, that effect will also show the Gui image and will turn it off once it ends.

Effect script:

local human = script.Parent.Humanoid
local walk = human.WalkSpeed
local jump = human.JumpPower
local speedcontrolF = nil
local jumpcontrolF = nil
script:GetAttributeChangedSignal("Burn"):Connect(function()
	if script:GetAttribute("Burn") then
		for i = 1, 20, 1 do
			human.Health = math.ceil(human.Health - human.MaxHealth / 50)
			wait(0.5)
		end
		
		script:SetAttribute("Burn",false)
	end
end)
script:GetAttributeChangedSignal("Poison"):Connect(function()
	if script:GetAttribute("Poison") then
		for i = 1, 10, 1 do
			human.Health = math.ceil(human.Health - human.Health / 10)
			wait(1)
		end

		script:SetAttribute("Poison",false)
	end
end)
script:GetAttributeChangedSignal("Bleed"):Connect(function()
	if script:GetAttribute("Bleed") then
		human.Health = math.ceil(human.Health - 20)
		human.MaxHealth = human.MaxHealth - 50
		for i = 1, 20, 1 do
			human.Health = math.ceil(human.Health - human.MaxHealth / 20)
			wait(1)
		end
		human.MaxHealth = human.MaxHealth + 50
		human.Health = math.ceil(human.Health + 50)
		script:SetAttribute("Bleed",false)
	end
end)
script:GetAttributeChangedSignal("Freeze"):Connect(function()
	if script:GetAttribute("Freeze") then
		speedcontrolF = human.WalkSpeed
		jumpcontrolF = human.JumpPower
		human.WalkSpeed = 0
		human.JumpPower = 0
		for i = 1, 20, 1 do
			human.Health = math.ceil(human.Health - human.MaxHealth / 50)
			wait(0.5)
		end
		human.WalkSpeed = speedcontrolF
		human.JumpPower = jumpcontrolF
		script:SetAttribute("Freeze",false)
	end
end)

Here is the gui manager:

repeat wait(1) until game:IsLoaded()
local player = game.Players.LocalPlayer
local char = player.Character

local Effects = char.EffectScript
local mainui = player.PlayerGui.UserInterface["Health Frame"]["Effect Indicators"]
print(mainui)
script:GetAttributeChangedSignal("Burn"):Connect(function()
	if Effects:GetAttribute("Burn") then
	mainui.Burn.ImageTransparency = 0
	else
		mainui.Burn.ImageTransparency = 1
	end
end)
script:GetAttributeChangedSignal("Poison"):Connect(function()
	if Effects:GetAttribute("Poison") then
	
		mainui.Poison.ImageTransparency = 0
	
	else
		mainui.Poison.ImageTransparency = 1
	end
end)
script:GetAttributeChangedSignal("Bleed"):Connect(function()
	if Effects:GetAttribute("Bleed") then
	
		mainui.Bleed.ImageTransparency = 0
	else
		mainui.Bleed.ImageTransparency = 1
	end
end)
script:GetAttributeChangedSignal("Freeze"):Connect(function()
	if Effects:GetAttribute("Freeze") then
		mainui.Freeze.ImageTransparency = 0
	else
		mainui.Freeze.ImageTransparency = 1
	end
end)

UiProblem

This is a reupload of an unsolved problem because i still need to solve the problem, Comments From previous uploads will show up here!



Wouldn’t it be much more better for you to just fire an event to enable and disable it (this is how I manage my UserInterface)?

what do you mean by enable and disable it?

By enabling and disabling, I meant this:

-- or 1 if you want to disable it.
mainui.Poison.ImageTransparency = 0
1 Like

Couldn’t you also use mainui.Enabled = false?

then it would enable and disable the entire set of icons would it?

Wait, Isn’t GetAttributeChangedSignal an event?

[Sorry for the late reply] but yes it is an event but I’d recommend sending an event to enable or disable your UserInterface. If you don’t want to do that then it seems like your GuiManager script is using it’s own attributes rather than listening to an event used by the effect script itself, I think if you fix that, then it should work.

1 Like

wait i thought i did somthing that works imma look more into this

Alright now it works, Thank you!