I need to make this script so that if a part touches the expanding red ball, it will 'liquify'. I put in a print command, but it only fires if it comes in contact with a player. Here's the code.
script.Parent.Touched:Connect(function(hit) print("Liquify touch") if not hit:IsDescendantOf(workspace.ReactorCore) then local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid ~= nil then local flame = Instance.new("Fire", hit.Parent.HumanoidRootPart) flame.Color = script.Parent.Color wait(1) for _,v in pairs(hit.Parent:GetChildren()) do if v:IsA("BasePart") then v.BrickColor = BrickColor.new("Really red") v.Material = Enum.Material.Neon end end wait(1) local explosion = Instance.new("Explosion", workspace) explosion.Position = hit.Parent.HumanoidRootPart.Position humanoid.Health = 0 elseif humanoid == nil then print("Melting") hit.BrickColor = script.Parent.BrickColor hit.Material = Enum.Material.Neon wait(2) hit.Anchored = false end end end)
If anyone can tell me why it isn't working, I'd be very grateful.
UPDATE: I have discovered that it will only melt unanchored parts. Does anyone know the cause of this?
did you by any chance turn CanTouch to false
This maybe worth a try. Try changing hit
to plr
Make sure you change all the hit
to the plr
Hope this works!!
I am quite confused as to why this is happening. You can follow this link to a Roblox place, because in that place it works fine.