Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How i can make this compatible with uppertorso?

i cant make this work with both character types

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function()
		script:WaitForChild("Music")
		script:WaitForChild("RadioGui")
		game.Workspace:WaitForChild(Player.Name)

		local Sound = script.Music:Clone()
		local Gui = script.RadioGui:Clone()
		Sound.Parent = Player.Character.Torso --<-- this line
		wait(1)
		Gui.Parent = Player.PlayerGui
		Gui.Enabled = true
	end)
end)

1 comment

0

replace it with Player.Character.HumanoidRootPart, it's compatible with all character rig types.

2 answers

I fixed that this is another script but they are similar

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function()
		script:WaitForChild("Radio")
		script.Radio:WaitForChild("RadioGui")
		game.Workspace:WaitForChild(Player.Name)

		local Radio = script.Radio:Clone()
		local Gui = script.Radio.RadioGui:Clone()

		local Weld = Instance.new("ManualWeld")
		
		Radio.Parent = Player.Character
		Radio.Transparency = 0
		Radio.Anchored = false
		if Player.Character:WaitForChild("Torso") then
			Weld.Parent = Radio
			Weld.Part0 = Radio
			Weld.Part1 = Player.Character.Torso
		else
			Weld.Parent = Radio
			Weld.Part0 = Radio
			Weld.Part1 = Player.Character.UpperTorso
		end
		Weld.C0 = CFrame.new(0.25, 0.55, 0.75, -1, 0.3, 0, 0.3, 1, 0, 0, 0, -1)*CFrame.new(0, -math.pi/5, 0)
		wait(1)
		Gui.Parent = Player.PlayerGui
		Gui.Enabled = true
	end)
end)

A check for what RigType the player is using would be good, make a line of code for each one

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function()
	        script:WaitForChild("Music")
	        script:WaitForChild("RadioGui")
	        game.Workspace:WaitForChild(Player.Name)
	
	        local Sound = script.Music:Clone()
	        local Gui = script.RadioGui:Clone()
		
		Player.Character:WaitForChild("Humanoid")
		
		if Player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		        Sound.Parent = Player.Character.UpperTorso
		else
			Sound.Parent = Player.Character.Torso
		end
	
	        wait(1)
	        Gui.Parent = Player.PlayerGui
	        Gui.Enabled = true
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.