So when I was trying to create a module script where when a player tries to insert a NPC through the script and by using the functions from the module. The inserting of npc works by duplicating the previous model from the module script and putting it inside of the workspace. The problem is that when i tried to run the code, it won’t appear the sound and it won’t change colours.
Code inherited from the Module script that had a error
First:
BotMaker.AddColor = function(BrickColourr)
for i, v in pairs(ClonedR6:GetChildren()) do
if v:IsA("BasePart") then
v.BrickColor = BrickColourr
end
end
for i, v in pairs(ClonedR15T1:GetChildren()) do
if v:IsA("BasePart")then
v.BrickColor = BrickColourr
end
end
for i, v in pairs(ClonedR15T2:GetChildren()) do
if v:IsA("BasePart")then
v.BrickColor = BrickColourr
end
end
end
Second:
BotMaker.AddSoundPreview = function(enabled, SoundID)
local SoundService = game:GetService("SoundService")
--setting
SoundService.DopplerScale = 12
SoundService.DistanceFactor = 10
if enabled == true then
print("dONE")
local Sound = Instance.new("Sound")
Sound.Parent = workspace
Sound.SoundId = SoundID
Sound.Name = "NewSound"
while enabled and SoundService.DistanceFactor <= 10 do
Sound:Play()
wait(Sound.TimeLength)
end
end
end
and lastly the script from the serverscript:
local Module = require(game.ReplicatedStorage["BotMaker V.1"])
Module.CreateNewBot("R6", "NPC", 100, 60, 16, "MEDIUM")
Module.AddColor(BrickColor.new("Bright blue"))