I have a ragdoll script and basically before it ragdolls I want it to play a screaming noise. I have the screaming noise script done and it's in a ModuleScript located in workspace, as the ragdoll script is located in StarterCharacterScripts. Here are my scripts.
ModuleScript in Workspace:
local module = {} function module.scream() local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(Player) wait() Player.CharacterAdded:Connect(function(Character) local Sound1 = Instance.new('Sound') Sound1.Name = "Scream1" Sound1.SoundId = "rbxassetid://337804578" local Sound2 = Instance.new('Sound') Sound2.Name = "Scream2" Sound2.SoundId = "rbxassetid://337804646" Sound1.Parent = Character:WaitForChild("Head") Sound2.Parent = Character:WaitForChild("Head") local screams = math.random(1,2) if screams == 1 then Character.Head.Scream1:Play() end if screams == 2 then Character.Head.Scream2:Play() end end) end) end return module
Ragdoll script in StarterCharacterScripts:
repeat wait() until script.Parent:IsA("Model") local char = script.Parent local R6 = require(script.R6) local R15 = require(script.R15) local plr = game:GetService("Players"):GetPlayerFromCharacter(char) local hum = char:WaitForChild("Humanoid") local autoLoads = game:GetService("Players").CharacterAutoLoads local modulescript = require(game.Workspace.ModuleScript) local function setNetworkOwner() for i, bp in pairs(char:GetChildren()) do if bp:IsA("BasePart") and bp:CanSetNetworkOwnership() then bp:SetNetworkOwner(plr) end end end hum.Died:Connect(function() if hum.RigType == Enum.HumanoidRigType.R6 then R6(char) setNetworkOwner() if autoLoads then delay(3, function() plr:LoadCharacter() end) end else R15(char) modulescript.scream(char) setNetworkOwner() if autoLoads then delay(3, function() plr:LoadCharacter() end) end end end)
For some reason, it ragdolls but it doesn't require/call the ModuleScript, or it just doesn't work. Can anyone help me out?