So basically my script works once or twice but then shows a Roblox error and I don't know how to fix it. Down here is what it says when I touch the 2 parts. (1 part burns me and the other extinguishes the fire)
The Parent property of Fire is locked, current parent: NULL, new parent Handle
PART 1
f = Instance.new("Fire") script.Parent.Touched:Connect(function(Touch) if not Touch:FindFirstChild("Humanoid") then f.Parent = Touch print(Touch.Name) end end)
PART 2
script.Parent.Touched:Connect(function(water) if water:FindFirstChild("Fire") then water.Fire:Destroy() end end)
Firstly, you can place both functions into the same connection (you'd only need one script), since you want these to occur chronologically, you'd place the water code after the adding fire code.
script.Parent.Touched:Connect(function(Touch) local f = Instance.new("Fire") if not Touch:FindFirstChild("Humanoid") then f.Parent = Touch print(Touch.Name) end if Touch:FindFirstChild("Fire") then Touch.Fire:Destroy() end end)
For the second script, if you keep two separate ones, you can also change the .Touched
to a .ChildAdded
event, where the parameter is the added instance
Revision Script 2
script.Parent.ChildAdded:Connect(function(fire) if fire.Name == "Fire" then fire:Destroy() end end)
You should also place the "fire" into the event connection since creating the fire outside of the connection will result in only ever having one "Fire" instance