Hello, I’ve been trying to make a boombox that welds to your torso when unequipped. but I cant get it to work. Help would be much appreciated
what troubles r u having, are any errors showing?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BackTools = ReplicatedStorage:WaitForChild("BackTools")
local Character = script.Parent
local UpperTorso = Character:FindFirstChild('UpperTorso') or Character:FindFirstChild('Torso')
local OldModel = nil
function Weld(weldMe, toThis)
local weld = Instance.new("Weld")
weld.Part0 = weldMe
weld.Part1 = toThis
weld.C0 = weldMe.CFrame:ToObjectSpace(toThis.CFrame)
weld.Parent = toThis
end
Character.ChildAdded:Connect(function(child)
if OldModel.Name == child.Name then
OldModel:Destroy()
end
end)
Character.ChildRemoved:Connect(function(child)
local Model = BackTools:FindFirstChild(child.Name)
if child:IsA('Tool') and Model then
if OldModel then
OldModel:Destroy()
end
OldModel = Model:Clone()
OldModel:SetPrimaryPartCFrame(UpperTorso.CFrame)
OldModel.Parent = workspace
Weld(OldModel.PrimaryPart, UpperTorso)
end
end)
here is our weld code but the problem is that the music doesn’t continue playing after unequipping.
show the script that plays the song and everything
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Remote = Tool:WaitForChild("Remote")
local Sound = Handle:WaitForChild("Sound")
function onUnequip()
Sound:Stop()
end
function onActivate()
Remote:FireClient(getPlayer(), "ChooseSong")
end
function getPlayer()
return game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
end
function playSong(id)
id = id or ""
if Sound then
Sound:Destroy()
end
Sound = Instance.new'Sound'
Sound.Parent = Handle
Sound.Volume = 0.4
Sound.Looped = true
Sound.PlayOnRemove = false
Sound.SoundId = "http://www.roblox.com/asset/?id="..id
Sound:Play()
local shakevalue = Instance.new("ObjectValue")
local addedvalue = Instance.new("IntValue")
local bright = Instance.new("IntValue")
local distance = Instance.new("IntValue")
local shake = Instance.new("IntValue")
shakevalue.Parent = game.ReplicatedStorage.MonitorSoundsFolder
shakevalue.Name = "Boomboxshake"
shakevalue.Value = Sound
--
shake.Parent = shakevalue
shake.Name = "ShakeMValue"
shake.Value = 1
--
bright.Parent = shakevalue
bright.Name = "BrightMValue"
bright.Value = 1
--
addedvalue.Parent = shakevalue
addedvalue.Name = "AddedValue"
addedvalue.Value = 1
--
distance.Parent = shakevalue
distance.Name = "DistanceValue"
distance.Value = 6
end
function onRemote(player, func, ...)
if player ~= getPlayer() then return end
if func == "Activate" then
onActivate(...)
end
if func == "PlaySong" then
playSong(...)
end
end
Remote.OnServerEvent:connect(onRemote)
Tool.Unequipped:connect(onUnequip)
ignore the shake part.
If I read it right it’s because the music is being parented to the tool. So when you unequip it the sound is inside player playing so you don’t hear it. Instead parent it to a part inside the character.
Isn’t it against the tos to repost something
I don’t think this is a repost. But they say, “Every reply must be meaningful, contributive, and on-topic. Do not re-post what others have already said, do not post memes or single-word posts such as “First!” or “bump”, and put effort into your posts.” so yeah it is. Official Rules of the Roblox Developer Forum
u have that the sound stops on unequip, instead parent the sound to the backradio