My code will not damage the player when the Bool value is set to true!

My code isn’t working properly!

  1. What do you want to achieve? I want a fish in my game to give a sort of “burning” effect, and when you are touched by the fish, you catch on fire!

  2. What is the issue? It gives me the error “OnFire (the bool value) is not a valid member of [PLAYER]”.

  3. What solutions have you tried so far? I’ve tried making changes to how it checks for the bool, but it still doesn’t detect it.

Heres the script inside of the fish:

script.Parent.Touched:Connect(function(hit)
	local char = hit.Parent
	if char then
		hit.Parent.OnFire = true
	end
end)

Heres the script inside of the player being set on fire:

while true do
	local onFire = script.Parent.OnFire
	if onFire.Value == true then
		script.Parent.Humanoid.Health = script.Parent.Humanoid.Health - 5
	end
	wait(1)
end

Here is my explorer window:
explorer window in roblox studio fishy business bug

Thank you if you can help me! If you need me to provide more info, please tell me!

How does the givefireboolean script work?
Does it add the bool value immediately? Or does it wait for a fish to touch?

could it possibly be that you forgot to add .Value

The issue here is because you are not adding .Value to the end of your OnFire's here. Also, have you considered maybe using .Changed instead of a loop which is always running detecting if the Value has changed? It might be better for your use case here, although I don’t know more about your use case so I’m unsure, just a suggestion.

2 Likes

you shouldnt store the bool value in player as client side scripts can access them.

meaning exploiters can easily make themselves immune to the fish.

It gives it on spawn! Thank you for helping me if you can!