i have this script and was wondering any way that when the function is activated, along with what it should do, it also stops all sounds in soundservice, i tried for 30 min and cant find a way
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateRigEvent = ReplicatedStorage:WaitForChild("UpdateRig")
local StarterPlayer = game:GetService("StarterPlayer")
local TypeOfRig = ReplicatedStorage:WaitForChild("TypeOfRig")
local function updateRig(username)
local player = Players:GetUserIdFromNameAsync(username)
if player then
local character = Players:CreateHumanoidModelFromUserId(player)
if character then
local rig = workspace:FindFirstChild("Rig")
local rigPosition = rig and rig:GetPivot() or CFrame.new(0, 0, 0)
if rig then
rig:Destroy()
end
character.Name = "Rig"
character.Humanoid.DisplayName = username
character.Parent = workspace
character:PivotTo(rigPosition)
-- Adjust the position to ensure it's not stuck in the ground
local rootPart = character:FindFirstChild("HumanoidRootPart")
if rootPart then
rootPart.CFrame = rigPosition + Vector3.new(0, 0, 0) -- Adjust the Y offset as needed
end
-- Detect rig type and update TypeOfRig StringValue
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
if humanoid.RigType == Enum.HumanoidRigType.R6 then
TypeOfRig.Value = "R6"
print("New rig is R6")
elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
TypeOfRig.Value = "R15"
print("New rig is R15")
else
warn("Unknown rig type detected")
end
else
warn("Humanoid not found in the new character")
end
else
warn("Failed to create character for user: " .. username)
end
else
warn("Failed to get player from username: " .. username)
end
end
UpdateRigEvent.OnServerEvent:Connect(function(player, username)
updateRig(username)
end)