Attempting to make a boombox that when unequipped goes to your back, having problems

hello everyone!

i’ve been trying to make a boombox that sticks to your back when unequipped, although, as the title says: i’m getting a problem

after testing with two people: i used the boombox, and unequipped it:
my friend who tested with me told me he couldn’t hear it at all, or see the boombox, and i realized: “oh damn it this entire thing is client-sided”, and i need some help making it work on the server, which would be pretty damn helpful.
here’s the structure of the tool
image
(rgui is the gui for the playing itself.)
the server script:

local root = script.Parent

local play = root.play
local song = root.Handle:WaitForChild("Sound")

root.Unequipped:Connect(function()
	song.Volume = 0
end)
root.Equipped:Connect(function()
	song.Volume = 1
end)

play.OnServerEvent:Connect(function(plr, sid)
	sid = tonumber(sid)
	if not sid then
		song:Stop()
		return
	end
	song.SoundId = "rbxassetid://".. sid
	song:Play()
end)

and here’s the local script:

local tool = script.Parent
local event = tool.play

repeat wait() until plr.Character
local rGui = nil
local con = nil
local rcons = {}

tool.Equipped:Connect(function(mouse)
	con = tool.Activated:Connect(function()
		if rGui == nil then
			rGui = tool:WaitForChild("rGui"):Clone()
			local mf = rGui:WaitForChild("MainFrame")
			local tb = mf:WaitForChild("TextBox")
			table.insert(rcons,
				mf:WaitForChild("PlaySong").Activated:Connect(function()
					event:FireServer(tb.Text)
				end)
			)
			table.insert(rcons,
				mf:WaitForChild("StopSong").Activated:Connect(function()
					event:FireServer(0)
				end)
			)
			
			rGui.Parent = plr.PlayerGui
		end
	end)
end)
tool.Unequipped:Connect(function()
	if rGui ~= nil then
		rGui:Destroy()
		rGui = nil
	end
	for _,v in pairs({table.unpack(rcons), con}) do
		if v then
			v:Disconnect()
		end
	end
	table.clear(rcons)
end)

i’m unsure if the weld script is needed, but if anyone needs it: please tell me in the replies, i’ll send it.
thanks everyone! hope someone can help me out here. :happy1:

in root.Unequipped on the server script, add your welding code

it’s a complete 50+ line monster though, are you sure?

Why is your weld script so long? All you need is to weld the Boombox.PrimaryPart to the HumanoidRootPart with the proper offset and rotation using C0 and C1.

1 Like