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

The script won't disable in a other script, how can i fix this?

Asked by 2 years ago

Hello, i have now an idea how i make the "Nature Sounds" (day/night) off when the player goes in the region. I had watched a video from AlvinBlox named "SoundRegions" i toke that script and modified it so that if the player goes in a region the day/night sound script will stop and if the player leave it will does again what it should do, but the problem is now it won't disable the script. I will show you the scripts down below, and i hope somebody could help me.

AlvinBlox's script (modified)

local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions")

local Found = false

while wait(0) do

    for i, v in pairs (SoundRegionsWorkspace:GetChildren()) do

        Found = false
        local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))

        local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())


        for _, part in pairs(parts) do
            -- Loop one by one through the parts table
            if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
                print("Player was found")
                Found = true
                break
            else
                Found = false
                print("Player was not found in region")
            end
        end

        if Found == true then
            -- Start playing some music
            if script.Parent.SoundRegions[v.Name].IsPlaying == false then
                script.Parent.Parent.ServerScriptService.NatureSound.Disabled = true
                script.Parent.SoundRegions[v.Name]:Play()

                break
            end
        else
            script.Parent.SoundRegions[v.Name]:Stop()
            script.Parent.Parent.ServerScriptService.NatureSound.Disabled = false
        end

    end
end

The output will show this if i play the game: ServerScriptService is not a valid member of Player "Players.ThebigGrow41"

0
Where i modified is: script.Parent.Parent.ServerScriptService.NatureSound.Disabled = false and script.Parent.Parent.ServerScriptService.NatureSound.Disabled = true ThebigGrow41 2 — 2y

Answer this question