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

Descendantadded not firing at all?

Asked by 2 years ago
Edited 2 years ago

im trying to make it so that the enemy moves to the sound value parent's position but descendantadded is not firing...

local debounce = false
local prevpath = nil

workspace.DescendantAdded:Connect(function(sound)
    -- for i,sound in pairs(workspace:GetDescendants()) do
        if sound.Name == "Soundvalue" and sound:IsA("StringValue") then
                         print("Founded")
             local hrp = script.Parent:WaitForChild("Torso")
             local ischasing = script.Parent:WaitForChild("Ischasing")

             if ischasing.Value == false then
                 if not debounce then
                    debounce = true

                     if prevpath ~= nil then
                        prevpath:Destroy()
                     end

                    if sound.Parent and sound.Parent:IsA("BasePart") then
                        print("aaaaa")
                                  local path = game:GetService("PathfindingService"):CreatePath()
                        path:ComputeAsync(hrp.Position, sound.Parent.Position)

                        local waypoints = path:GetWaypoints()

                        prevpath = path

                        for i,waypoint in pairs(waypoints) do
                            if ischasing.Value == false then
                                script.Parent.Enemy:MoveTo(waypoint.Position)
                                script.Parent.Enemy.MoveToFinished:Wait()
                            end
                        end
                    end

                    debounce = false
                 end                
             end
         end
    --end
end)
0
Did you try use 'print' to check if it actually fired? AProgrammR 398 — 2y
0
hold on lemme try GameBuilderLol 58 — 2y
0
yea i did put a little print thingy under the if statement for the soundvalues but nothing printed GameBuilderLol 58 — 2y
0
It will be very funny if you add them first then change name to what you want, or I can't find why they dont find your sound TerranRecon 49 — 2y
View all comments (4 more)
0
put print(sound.Name) on line 5 and test TerranRecon 49 — 2y
0
isnt the name SoundValue not Soundvalue? jerryisgod29 176 — 2y
0
its Soundvalue GameBuilderLol 58 — 2y
0
its Soundvalue GameBuilderLol 58 — 2y

Answer this question