Hi! I’m basically remaking the BoomBox into a more modern way (click a button to open a gui, enter the audio id → it welds the BoomBox to your back and plays the sound).
My problem is that the sound doesn’t play at all. Any idea what is causing this? The audios load and play in Toolbox without any problems, just not in-game in the BoomBox.
LocalScript
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("HUD").BoomboxMenu
repeat wait() until plr.Character
local TextBox = script.Parent.Box
local PlayButton = script.Parent.Play
local RS = game:GetService("ReplicatedStorage")
local EventBoombox = RS:FindFirstChild("BoomboxEvent")
PlayButton.MouseButton1Click:Connect(function()
if TextBox.Text ~= "" then
gui:TweenPosition(UDim2.new(0.5,0,1.5,0), 'InOut', 'Sine', 1)
EventBoombox:FireServer("play", TextBox.Text)
wait(1.5)
gui.Visible = false
TextBox.Text = ""
elseif TextBox.Text == "" then
gui:TweenPosition(UDim2.new(0.5,0,1.5,0), 'InOut', 'Sine', 1)
EventBoombox:FireServer("remove", TextBox.Text)
wait(1.5)
gui.Visible = false
TextBox.Text = ""
end
end)
ServerScript
local RS = game:GetService("ReplicatedStorage")
local BoomboxPart = RS:FindFirstChild("BoomboxPart")
local BoomboxEvent = RS:FindFirstChild("BoomboxEvent")
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true)
local function playMusic(tween, partClone, soundId)
tween:Play()
partClone.Sound.SoundId = "rbxassetid://"..soundId
partClone.Sound:Play()
partClone.Sound.Looped = true
end
BoomboxEvent.OnServerEvent:Connect(function(plr, value, soundId)
if value == "play" then
if plr.Character:WaitForChild("HumanoidRootPart"):FindFirstChild("BoomboxPart") then
local part = plr.Character:WaitForChild("HumanoidRootPart"):FindFirstChild("BoomboxPart")
local tween = TS:Create(part, info, {Size = Vector3.new(3.499, 1.75, 1.312)})
playMusic(tween, part, soundId)
else
local partClone = BoomboxPart:Clone()
partClone.Parent = plr.Character:WaitForChild("HumanoidRootPart")
local weld = partClone:WaitForChild("Weld")
weld.Part0 = partClone
weld.Part1 = plr.Character:WaitForChild("HumanoidRootPart")
local tween = TS:Create(partClone, info, {Size = Vector3.new(3.499, 1.75, 1.312)})
playMusic(tween, partClone, soundId)
end
elseif value == "remove" then
local BoomboxPart = plr.Character:WaitForChild("HumanoidRootPart"):FindFirstChild("BoomboxPart")
BoomboxPart.Sound:Stop()
BoomboxPart:Destroy()
end
end)