Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How i can make this compatible with uppertorso?

Asked by
AIexR32 11
4 years ago

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)
0
replace it with Player.Character.HumanoidRootPart, it's compatible with all character rig types. User#31525 30 — 4y

2 answers

Log in to vote
0
Answered by
AIexR32 11
4 years ago

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)

Ad
Log in to vote
0
Answered by 4 years ago

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)

Answer this question