Effect Script Not Working

Hi, I am a new developer/scripter that is trying to get a script to work, the script being a script that controls effects (Burn, Freeze, Poison, Etc…)

to test the effect script out, I had a part to turn on the effect and the effect to execute an action if it is on. I just need some way for the part to turn on the effect. And a script for that player that could execute an action when that effect is on.

The mechanics for the part setting the effect are ok, But the script that is in charge for executing the effect action doesn’t work. And the part also has its own flaws, even the part that turns on the effect can only do it once, otherwise it dosen’t work.

effect script code:

local burnval = script:GetAttribute("Burn")

script:GetAttributeChangedSignal(function()
	if burnval == true then
		print("is burning")
	end
end)

burn part code:

local part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if hit.Parent:FindFirstChild("EffectScript"):GetAttribute("Burn") == true then
			print("already burned")
		elseif hit.Parent:FindFirstChild("EffectScript"):GetAttribute("Burn") == false then
			hit.Parent.EffectScript:SetAttribute("Burn",true)
			print("set")
		else
			print("none")
		
		end
	end
end)

ill post more info once I find out how to.

I tried using bool values and attributes, but they don’t work.

im sorry if it is hard to read, this is also the first time im writing a help request like this.

GetAttributeChangedSignal expects you to give it an attribute to listen for changes to, also your code wouldn’t work even if you do that because you store the initial value of Burn in a variable rather than checking when needed

script:GetAttributeChangedSignal("Burn"):Connect(function()
	if script:GetAttribute("Burn") then
		print("is burning")
	end
end)
1 Like

Thank you for letting me know, the burn execution works but the part is still a problem since even if i turn the attribute off, it still only works once.

How do you turn the attribute off? Likely something is up with how you set it back to false

i apologize for not sending a recording but in the game, i went to my own character model which contains the script and turned the attribute off manually when i played the game. but when i stepped on the part it already said it turned it on even when i just turned it off.

output that relates to this topic:

  13:08:16.529  set  -  Server - Script:9
  13:08:16.629   ▶ already burned (x17)  -  

set means the part set the attribute to true and already burned tells me that the attribute is already true, when i turned it off manually it still says it burned.

I think in that case you’re setting the Burn attribute to false from the Client rather than fro mthe server, when Testing, there should be a button on the top of the screen in the Test tab that says “Testing: Client” or similar, press it to view from the server and then set the Attribute to false

1 Like

ok i get it now, thank you for the help!

1 Like