(Roblox Lua newbie here)
So I've been making these two bricks. One of them would light up the player with fire(and smoke) and the other one would remove the effects. (I still have yet to add damage)
The thing is, those two functions only work once. In other words, when the player touches the lava brick(effects appear) then the water brick(effects disappear) and then when the player touches the lava brick once again effect doesn't reappear.
Error: The parent property of fire is locked, current parent: NULL, new parent Torso.
Here's what I currently have:
local lava = game.Workspace.Lava local water = game.Workspace.Water aflame = Instance.new("Fire") local newSmoke = game.Workspace.Prefabs.Part.Smoke:clone() function onFire(bpart) aflame.Parent = bpart.Parent.Torso newSmoke.Parent = bpart.Parent.Torso end end lava.Touched:Connect(onFire) function fireGone(bpart) local fireRemove = bpart.Parent.Torso:FindFirstChild("Fire") local smokeRemove = bpart.Parent.Torso:FindFirstChild("Smoke") if fireRemove then fireRemove:Destroy() smokeRemove:Destroy() end end water.Touched:Connect(fireGone)
Any help is greatly appreciated.
You need to clone the instance of the fire and smoke everytime the function is called somehow like this:
local lava = game.Workspace.Lava local water = game.Workspace.Water aflame = Instance.new("Fire") local newSmoke = game.Workspace.Prefabs.Part.Smoke:clone() function onFire(bpart) local f = aflame:Clone() local s = newSmoke:Clone() f.Parent = bpart.Parent.Torso s.Parent = bpart.Parent.Torso end function fireGone(bpart) local f = bpart.Parent.Torso:FindFirstChild("Fire") local s = bpart.Parent.Torso:FindFirstChild("Smoke") if f then f:Destroy() s:Destroy() end end water.Touched:connect(fireGone) lava.Touched:connect(onFire)