Boombox position is off when changing scale of mesh

image
As you can see here, the boombox position is off when changing the scale of the mesh, almost as if it’s always centered (which I don’t want it to). What I want to achieve is a boombox that changes in a repeat dependent to a certain song’s playbackloudness (keep in mind I’m using a remotefunction on the client to receive the playbackloudness because the property is client-only) but I can’t seem to get the boombox to position right on the ground. I’ve come into this problem again, but this wasn’t as complicated as the certain qualities I’m trying to achieve. Here’s my script if you want to look into it:

Script (server-side)
plr.Chatted:Connect(function(msg)
	if msg == "/e dance" then
		local char = plr.Character or plr.CharacterAdded:Wait()
		local hum = char:WaitForChild("Humanoid")
		local hrp = char:WaitForChild("HumanoidRootPart")
		local animator = hum:FindFirstChildOfClass("Animator")
		if not hrp:FindFirstChild("DanceSound") then
			local newSound = Instance.new("Sound", hrp)
			newSound.Name = "DanceSound"
			newSound.SoundId = "rbxassetid://13377293797"
			newSound.Volume = 2
			newSound.RollOffMaxDistance = 50
			newSound.RollOffMinDistance = 10
			newSound.Looped = true
			newSound:Play()
			local anim = Instance.new("Animation")
			anim.AnimationId = "rbxassetid://13377190638"
			local breakdance = animator:LoadAnimation(anim)
			breakdance.Looped = true
			breakdance:Play()
			local hrpOrientation = getHRP:InvokeClient(plr)
			local spotlight = rs:WaitForChild("SpotLight"):Clone()
			spotlight.Position = Vector3.new(hrp.Position.X, hrp.Position.Y+6, hrp.Position.Z)
			spotlight.Parent = char
			local offset = Vector3.new(5, -1.168, -4)
			local boombox = rs:WaitForChild("Boombox"):Clone()
			boombox.CFrame = hrp.CFrame*CFrame.new(offset, Vector3.new(45, 0, -45))
			boombox.Parent = char
			local originalPos = boombox.CFrame.Position
			repeat
				local PlaybackLoudness = playback:InvokeClient(plr, newSound)
				local sizeVal = PlaybackLoudness/500
				if sizeVal > .2 then
					local mesh = boombox:FindFirstChildOfClass("SpecialMesh")
					if mesh then
						local tweenInfo = TweenInfo.new(
							0.2,
							Enum.EasingStyle.Quad,
							Enum.EasingDirection.InOut,
							0,
							false,
							0
						)
						TweenService:Create(boombox, tweenInfo, {
							Position = Vector3.new(boombox.Position.X, originalPos.Y-(sizeVal/(boombox.Size.Y*2)), boombox.Position.Z)
						}):Play()
						TweenService:Create(mesh, tweenInfo, {
							Scale = Vector3.new(2*sizeVal, 2*sizeVal, 2*sizeVal)
						}):Play()
					end
				end
				task.wait() 
			until hum.MoveDirection.Magnitude > 0
			newSound:Stop()
			newSound:Destroy()
			anim:Destroy()
			breakdance:Stop()
			breakdance:Destroy()
			spotlight:Destroy()
			boombox:Destroy()
		end
	end
end)

P.S. the only client-side written script is the remotefunction grabbing the playbackloudness of a passed sound (in this case the sound emitting from the boombox itself) and this is also using a tween which makes it even more complicated in my eyes

1 Like