Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

BasePart.Touched event not firing?

Asked by 2 years ago
Edited 2 years ago

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.

  • JB_SuperGamer

UPDATE: I have discovered that it will only melt unanchored parts. Does anyone know the cause of this?

0
The code *should* work as expected. Granted you never check if the hit was indeed the red ball. The red ball is not a descendant of ReactorCore, right? Shawnyg 4330 — 2y
0
is this a localscript or normal script? since touched doesnt work on localscripts LikeableEmmec 470 — 2y
0
No, the script is just a normal script, and no, the red ball is a descendant of ReactorCore JB_SuperGamer 165 — 2y

3 answers

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

did you by any chance turn CanTouch to false

0
Nope, all of the parts are set to CanTouch true JB_SuperGamer 165 — 2y
0
the script should work and is the ball descendant of reactorcore Puppynniko 1059 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

This maybe worth a try. Try changing hit to plr

Make sure you change all the hit to the plr Hope this works!!

0
Tried, had no difference JB_SuperGamer 165 — 2y
Log in to vote
0
Answered by 2 years ago

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.

0
(Set to Private, couldn't check) JB_SuperGamer 165 — 2y
0
sorry, updating now! LikeableEmmec 470 — 2y
0
alright, try it now. LikeableEmmec 470 — 2y

Answer this question