This is the server side script. The script is not mine so i don't know much about it but i can't find the reason it wouldn't work. It doesn't show any errors in output.

Thanks for your time

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 = 1
	Sound.Looped = true
	Sound.PlayOnRemove = false
	Sound.SoundId = "http://www.roblox.com/asset/?id="..id
	Sound:Play()
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)

1 comment

0

Don't post code that isn't yours; if you have no context as to what we're potentially helping with then frankly you don't deserve to be helped. Put forth the effort, and so will we :) Have a good day.