MP3 Player not positioning its self correctly

I want the MP3 player to position its self into the hand of the player.

Since the MP3 Player is not a tool, I must weld it to the arm of the player. The problem I am facing is that every time I “equip” the MP3 Player, it makes my character trip., and it doesn’t position its self properly.

I have tried pretty much everything. My script used to work fine besides the fact that it used to equip and unequip for a player who had an MP3 Player too. So I had to tweak it a little bit to get that to stop. (This involved putting the equipped boolean into a local script.)

-- serverscript
local replicatedstorage = game:GetService("ReplicatedStorage")
local animationID = 102621707329335
local holdingAnimationID = 127495954381443

replicatedstorage.Events.EquipPhone.OnServerEvent:Connect(function(player, action)
	-- Ensure the player owns the game pass
	if not game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 1004016496) then
		-- Prompt purchase if they don't own the game pass
		local success, errorMessage = pcall(function()
			game:GetService("MarketplaceService"):PromptGamePassPurchase(player, 1004016496)
		end)
		if not success then
			warn("Failed to prompt purchase: " .. errorMessage)
		end
		return
	end

	-- Get references
	local playergui = player.PlayerGui
	local mp3Rig = player.Character:FindFirstChild("mp3Rig")
	local mp3gui = playergui.MP3PlayerDisplay

	if action == "Equip" and mp3Rig and not mp3Rig:FindFirstChild("WeldConstraint") then
		-- Equip the MP3 player
		local mp3Player = mp3Rig.MP3Player
		local mp3PlayerPrimaryPart = mp3Player.PrimaryPart

		-- Position and weld the MP3 player
		local weld = Instance.new("WeldConstraint")
		weld.Parent = mp3PlayerPrimaryPart
		weld.Part0 = mp3PlayerPrimaryPart
		weld.Part1 = player.Character["Right Arm"]

		-- Position the MP3 player to Right Arm
		mp3Player:PivotTo(player.Character["Right Arm"].CFrame * CFrame.new(0, -1, -0.7) * CFrame.Angles(0, math.rad(180), 0))

		-- Enable the MP3 Player GUI
		mp3gui.Enabled = true

		-- Play animations
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			local animator = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", humanoid)

			-- Equip animation
			local equippedAnimation = Instance.new("Animation")
			equippedAnimation.AnimationId = "rbxassetid://" .. animationID
			local equippedAnimationTrack = animator:LoadAnimation(equippedAnimation)
			equippedAnimationTrack:Play()

			-- Loop holding animation after equip animation ends
			equippedAnimationTrack.Stopped:Connect(function()
				local holdingAnimation = Instance.new("Animation")
				holdingAnimation.AnimationId = "rbxassetid://" .. holdingAnimationID
				local holdingAnimationTrack = animator:LoadAnimation(holdingAnimation)
				holdingAnimationTrack.Looped = true
				holdingAnimationTrack:Play()
			end)
		end
	elseif action == "Unequip" and mp3Rig then
		-- Unequip the MP3 player
		local weld = mp3Rig.MP3Player.PrimaryPart:FindFirstChild("WeldConstraint")
		if weld then weld:Destroy() end
		mp3gui.Enabled = false

		-- Stop holding animation
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			for _, track in pairs(humanoid:GetPlayingAnimationTracks()) do
				if track.Animation.AnimationId == "rbxassetid://" .. holdingAnimationID then
					track:Stop()
					track:Destroy()
				end
			end
		end
	end
end)
-- client
local replicatedstorage = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local isequipped = false

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q then
		if not isequipped then
			replicatedstorage.Events.EquipPhone:FireServer("Equip") -- Tell server to equip
		else
			replicatedstorage.Events.EquipPhone:FireServer("Unequip") -- Tell server to unequip
		end
		isequipped = not isequipped -- Toggle the state locally
	end
end)

Video example of the problem:

Try to make the mp3 player be ‘Massless’ and also be ‘No Collision’

I believe I already have the MP3 Model as massless. Still does the same thing.

Try pivoting the MP3 player before you weld it to the player’s hand. Changing its Pivot/CFrame afterwards causes the character to teleport with the MP3 player, which is most likely what’s causing them to trip

1 Like

Thank you so much. That fixed the issue

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.